From b61eb2ff119be8b4f00b0e08874be17bce48f72f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 5 Jan 2025 11:37:38 -0600 Subject: [PATCH] Fix favourites of kind 20 events --- src/controllers/api/statuses.ts | 7 +++++-- src/queries.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index d466b551..38ed591a 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -290,7 +290,7 @@ const deleteStatusController: AppController = async (c) => { const contextController: AppController = async (c) => { const id = c.req.param('id'); const store = c.get('store'); - const event = await getEvent(id, { kind: 1, relations: ['author', 'event_stats', 'author_stats'] }); + const [event] = await store.query([{ kinds: [1, 20], ids: [id] }]); const viewerPubkey = await c.get('signer')?.getPublicKey(); async function renderStatuses(events: NostrEvent[]) { @@ -325,7 +325,8 @@ const contextController: AppController = async (c) => { const favouriteController: AppController = async (c) => { const id = c.req.param('id'); - const target = await getEvent(id, { kind: 1, relations: ['author', 'event_stats', 'author_stats'] }); + const store = await Storages.db(); + const [target] = await store.query([{ ids: [id], kinds: [1, 20] }]); if (target) { await createEvent({ @@ -337,6 +338,8 @@ const favouriteController: AppController = async (c) => { ], }, c); + await hydrateEvents({ events: [target], store }); + const status = await renderStatus(target, { viewerPubkey: await c.get('signer')?.getPublicKey() }); if (status) { diff --git a/src/queries.ts b/src/queries.ts index e93027d9..36066ce2 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -16,7 +16,7 @@ interface GetEventOpts { signal?: AbortSignal; /** Event kind. */ kind?: number; - /** Relations to include on the event. */ + /** @deprecated Relations to include on the event. */ relations?: DittoRelation[]; }