From e4892c3e4a44399357e23f4388427d207eb89b97 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Tue, 16 Apr 2024 14:44:04 -0300 Subject: [PATCH 1/2] fix: response with quote field hydrated in create status --- src/controllers/api/statuses.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 45f1209..209fb1a 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -130,6 +130,16 @@ const createStatusController: AppController = async (c) => { }, c); const author = await getAuthor(event.pubkey); + + if (data.quote_id) { + await hydrateEvents({ + events: [event], + relations: ['quote_repost'], + storage: eventsDB, + signal: c.req.raw.signal, + }); + } + return c.json(await renderStatus({ ...event, author }, { viewerPubkey: c.get('pubkey') })); }; From e19e41f8263cebfc190bba2dcb78bf2b0a7bcffc Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Tue, 16 Apr 2024 15:16:18 -0300 Subject: [PATCH 2/2] fix: always populate quote_id if possible --- src/views/mastodon/statuses.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/views/mastodon/statuses.ts b/src/views/mastodon/statuses.ts index 989bdef..37e86bf 100644 --- a/src/views/mastodon/statuses.ts +++ b/src/views/mastodon/statuses.ts @@ -76,8 +76,6 @@ async function renderStatus(event: DittoEvent, opts: statusOpts): Promise { const media = [...mediaLinks, ...mediaTags]; - const quoteStatus = !event.quote_repost ? null : await renderStatus(event.quote_repost, { depth: depth + 1 }); - return { id: event.id, account, @@ -105,8 +103,8 @@ async function renderStatus(event: DittoEvent, opts: statusOpts): Promise { tags: [], emojis: renderEmojis(event), poll: null, - quote: quoteStatus, - quote_id: quoteStatus ? quoteStatus.id : null, + quote: !event.quote_repost ? null : await renderStatus(event.quote_repost, { depth: depth + 1 }), + quote_id: event.tags.find(([name]) => name === 'q')?.[1] ?? null, uri: Conf.external(note), url: Conf.external(note), zapped: Boolean(zapEvent),