Merge branch 'refactor-unreblog' into 'main'

Mastodon API (Unreblog) - Query with Storages.db()

See merge request soapbox-pub/ditto!266
This commit is contained in:
Alex Gleason 2024-05-16 20:17:38 +00:00
commit cb2e8607fa
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({