From ae5fe1e0acb867f8ff53871e29a086b33efd5733 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 19 Apr 2024 10:23:34 -0300 Subject: [PATCH 1/2] fix: hydrate event_stats in hydrateRepostEvents() --- src/storages/hydrate.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/storages/hydrate.ts b/src/storages/hydrate.ts index 3fbce5f..e288084 100644 --- a/src/storages/hydrate.ts +++ b/src/storages/hydrate.ts @@ -139,7 +139,12 @@ async function hydrateRepostEvents(opts: Omit): P const originalPostEvent = results.find((event) => event.id === originalPostId); if (!originalPostEvent) continue; - await hydrateEvents({ events: [originalPostEvent], storage: storage, signal: signal, relations: ['author'] }); + await hydrateEvents({ + events: [originalPostEvent], + storage: storage, + signal: signal, + relations: ['author', 'event_stats'], + }); event.repost = originalPostEvent; } } From e2b377d9c7a7f47757948aafcec66d4a93f5b6df Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 19 Apr 2024 11:12:11 -0300 Subject: [PATCH 2/2] 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,