refactor(unreblog): update error messages and query with Storages.db()

This commit is contained in:
P. Reis 2024-05-16 10:29:14 -03:00
parent b2c26c9374
commit e61cbecb3e
1 changed files with 6 additions and 8 deletions

View File

@ -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({