mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-31 02:54:21 +01:00
Fix uploading (almost)
This commit is contained in:
@@ -4,16 +4,16 @@ import { UnattachedMedia } from '@/db/unattached-media.ts';
|
||||
|
||||
type DittoAttachment = TypeFest.SetOptional<UnattachedMedia, 'id' | 'pubkey' | 'uploaded_at'>;
|
||||
|
||||
function renderAttachment(media: DittoAttachment) {
|
||||
const { id, data, url } = media;
|
||||
function renderAttachment(tags: string[][]) {
|
||||
const url = tags.find(([name]) => name === 'url')?.[1];
|
||||
|
||||
const m = data.find(([name]) => name === 'm')?.[1];
|
||||
const alt = data.find(([name]) => name === 'alt')?.[1];
|
||||
const cid = data.find(([name]) => name === 'cid')?.[1];
|
||||
const blurhash = data.find(([name]) => name === 'blurhash')?.[1];
|
||||
const m = tags.find(([name]) => name === 'm')?.[1];
|
||||
const alt = tags.find(([name]) => name === 'alt')?.[1];
|
||||
const cid = tags.find(([name]) => name === 'cid')?.[1];
|
||||
const blurhash = tags.find(([name]) => name === 'blurhash')?.[1];
|
||||
|
||||
return {
|
||||
id: id ?? url,
|
||||
id: url,
|
||||
type: getAttachmentType(m ?? ''),
|
||||
url,
|
||||
preview_url: url,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { nostrDate } from '@/utils.ts';
|
||||
import { getMediaLinks, parseNoteContent } from '@/utils/note.ts';
|
||||
import { unfurlCardCached } from '@/utils/unfurl.ts';
|
||||
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
||||
import { DittoAttachment, renderAttachment } from '@/views/mastodon/attachments.ts';
|
||||
import { renderAttachment } from '@/views/mastodon/attachments.ts';
|
||||
import { renderEmojis } from '@/views/mastodon/emojis.ts';
|
||||
|
||||
interface RenderStatusOpts {
|
||||
@@ -78,16 +78,11 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
|
||||
|
||||
const mediaLinks = getMediaLinks(links);
|
||||
|
||||
const mediaTags: DittoAttachment[] = event.tags
|
||||
const imeta: string[][][] = event.tags
|
||||
.filter(([name]) => name === 'imeta')
|
||||
.map(([_, ...entries]) => {
|
||||
const data = entries.map((entry) => entry.split(' '));
|
||||
const url = data.find(([name]) => name === 'url')?.[1];
|
||||
return { url, data };
|
||||
})
|
||||
.filter((media): media is DittoAttachment => !!media.url);
|
||||
.map(([_, ...entries]) => entries.map((entry) => entry.split(' ')));
|
||||
|
||||
const media = [...mediaLinks, ...mediaTags];
|
||||
const media = [...mediaLinks, ...imeta];
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
|
||||
Reference in New Issue
Block a user