From e2b377d9c7a7f47757948aafcec66d4a93f5b6df Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 19 Apr 2024 11:12:11 -0300 Subject: [PATCH] fix: reblogged field boolean value takes into account viewerPubkey --- src/controllers/api/statuses.ts | 2 +- src/controllers/api/streaming.ts | 2 +- src/controllers/api/timelines.ts | 2 +- src/views/mastodon/statuses.ts | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 209fb1a..7838cc9 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -245,7 +245,7 @@ const reblogStatusController: AppController = async (c) => { signal: signal, }); - const status = await renderReblog(reblogEvent); + const status = await renderReblog(reblogEvent, { viewerPubkey: c.get('pubkey') }); return c.json(status); }; diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 8239645..40316be 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -73,7 +73,7 @@ const streamingController: AppController = (c) => { signal: AbortSignal.timeout(1000), }); - const status = await renderReblog(event); + const status = await renderReblog(event, { viewerPubkey: c.get('pubkey') }); if (status) { send('update', status); } diff --git a/src/controllers/api/timelines.ts b/src/controllers/api/timelines.ts index 467b115..7e0e323 100644 --- a/src/controllers/api/timelines.ts +++ b/src/controllers/api/timelines.ts @@ -63,7 +63,7 @@ async function renderStatuses(c: AppContext, filters: NostrFilter[]) { const statuses = (await Promise.all(events.map((event) => { if (event.kind === 6) { - return renderReblog(event); + return renderReblog(event, { viewerPubkey: c.get('pubkey') }); } return renderStatus(event, { viewerPubkey: c.get('pubkey') }); }))).filter((boolean) => boolean); diff --git a/src/views/mastodon/statuses.ts b/src/views/mastodon/statuses.ts index 37e86bf..9716d6f 100644 --- a/src/views/mastodon/statuses.ts +++ b/src/views/mastodon/statuses.ts @@ -111,7 +111,9 @@ async function renderStatus(event: DittoEvent, opts: statusOpts): Promise { }; } -async function renderReblog(event: DittoEvent) { +async function renderReblog(event: DittoEvent, opts: statusOpts) { + const { viewerPubkey } = opts; + if (!event.author) return; const repostId = event.tags.find(([name]) => name === 'e')?.[1]; @@ -119,8 +121,7 @@ async function renderReblog(event: DittoEvent) { if (!event.repost) return; - const reblog = await renderStatus(event.repost, {}); - reblog.reblogged = true; + const reblog = await renderStatus(event.repost, { viewerPubkey }); return { id: event.id,