From e61cbecb3e840100d6a4561a795f6ccab17d5cb4 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 16 May 2024 10:29:14 -0300 Subject: [PATCH] refactor(unreblog): update error messages and query with Storages.db() --- src/controllers/api/statuses.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 98173b0..984dfdb 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -261,21 +261,19 @@ const reblogStatusController: AppController = async (c) => { const unreblogStatusController: AppController = async (c) => { const eventId = c.req.param('id'); const pubkey = await c.get('signer')?.getPublicKey()!; - - const event = await getEvent(eventId, { kind: 1 }); - - if (!event) { - return c.json({ error: 'Event not found.' }, 404); - } - const store = await Storages.db(); + const [event] = await store.query([{ ids: [eventId], kinds: [1] }]); + if (!event) { + return c.json({ error: 'Record not found' }, 404); + } + const [repostedEvent] = await store.query( [{ kinds: [6], authors: [pubkey], '#e': [event.id], limit: 1 }], ); if (!repostedEvent) { - return c.json({ error: 'Event not found.' }, 404); + return c.json({ error: 'Record not found' }, 404); } await createEvent({