mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-21 06:14:24 +01:00
Add MastodonAttachment type
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { MastodonAttachment } from '@/entities/MastodonAttachment.ts';
|
||||
import { getUrlMediaType } from '@/utils/media.ts';
|
||||
|
||||
/** Render Mastodon media attachment. */
|
||||
function renderAttachment(media: { id?: string; data: string[][] }) {
|
||||
function renderAttachment(
|
||||
media: { id?: string; data: string[][] },
|
||||
): (MastodonAttachment & { cid?: string }) | undefined {
|
||||
const { id, data: tags } = media;
|
||||
|
||||
const url = tags.find(([name]) => name === 'url')?.[1];
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NostrEvent } from '@nostrify/nostrify';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { MastodonAttachment } from '@/entities/MastodonAttachment.ts';
|
||||
import { MastodonMention } from '@/entities/MastodonMention.ts';
|
||||
import { MastodonStatus } from '@/entities/MastodonStatus.ts';
|
||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
@@ -119,7 +120,9 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
|
||||
pinned: Boolean(pinEvent),
|
||||
reblog: null,
|
||||
application: null,
|
||||
media_attachments: media.map((m) => renderAttachment({ data: m })).filter(Boolean),
|
||||
media_attachments: media.map((m) => renderAttachment({ data: m })).filter((m): m is MastodonAttachment =>
|
||||
Boolean(m)
|
||||
),
|
||||
mentions,
|
||||
tags: [],
|
||||
emojis: renderEmojis(event),
|
||||
|
||||
Reference in New Issue
Block a user