Filter out attachments with no url

This commit is contained in:
Alex Gleason 2024-05-18 14:58:48 -05:00
parent e7d350a0e3
commit 91ea4577f1
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 2 deletions

View File

@ -12,8 +12,10 @@ function renderAttachment(tags: string[][]) {
const uuid = tags.find(([name]) => name === 'uuid')?.[1]; const uuid = tags.find(([name]) => name === 'uuid')?.[1];
const blurhash = tags.find(([name]) => name === 'blurhash')?.[1]; const blurhash = tags.find(([name]) => name === 'blurhash')?.[1];
if (!url) return;
return { return {
id: uuid, id: uuid ?? url,
type: getAttachmentType(m ?? ''), type: getAttachmentType(m ?? ''),
url, url,
preview_url: url, preview_url: url,

View File

@ -106,7 +106,7 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
pinned: Boolean(pinEvent), pinned: Boolean(pinEvent),
reblog: null, reblog: null,
application: null, application: null,
media_attachments: media.map(renderAttachment), media_attachments: media.map(renderAttachment).filter(Boolean),
mentions, mentions,
tags: [], tags: [],
emojis: renderEmojis(event), emojis: renderEmojis(event),