diff --git a/src/controllers/api/notifications.ts b/src/controllers/api/notifications.ts index dce75e4..bd8fe4d 100644 --- a/src/controllers/api/notifications.ts +++ b/src/controllers/api/notifications.ts @@ -13,7 +13,7 @@ const notificationsController: AppController = async (c) => { { timeout: Time.seconds(3) }, ); - const statuses = await Promise.all(events.map(toNotification)); + const statuses = await Promise.all(events.map((event) => toNotification(event, pubkey))); return paginated(c, events, statuses); }; diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 4544373..c7ad80c 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -29,7 +29,7 @@ const statusController: AppController = async (c) => { const event = await getEvent(id, { kind: 1 }); if (event) { - return c.json(await toStatus(event)); + return c.json(await toStatus(event, c.get('pubkey'))); } return c.json({ error: 'Event not found.' }, 404); @@ -74,7 +74,7 @@ const createStatusController: AppController = async (c) => { tags, }, c); - return c.json(await toStatus(event)); + return c.json(await toStatus(event, c.get('pubkey'))); } else { return c.json({ error: 'Bad request', schema: result.error }, 400); } @@ -115,7 +115,7 @@ const favouriteController: AppController = async (c) => { ], }, c); - const status = await toStatus(target); + const status = await toStatus(target, c.get('pubkey')); if (status) { status.favourited = true; diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 294b5d1..acbc545 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -63,7 +63,7 @@ const streamingController: AppController = (c) => { if (filter) { for await (const event of Sub.sub(socket, '1', [filter])) { - const status = await toStatus(event); + const status = await toStatus(event, pubkey); if (status) { send('update', status); } diff --git a/src/transformers/nostr-to-mastoapi.ts b/src/transformers/nostr-to-mastoapi.ts index 50bbee1..f4ee603 100644 --- a/src/transformers/nostr-to-mastoapi.ts +++ b/src/transformers/nostr-to-mastoapi.ts @@ -287,15 +287,15 @@ async function toRelationship(sourcePubkey: string, targetPubkey: string) { }; } -function toNotification(event: Event) { +function toNotification(event: Event, viewerPubkey?: string) { switch (event.kind) { case 1: - return toNotificationMention(event as Event<1>); + return toNotificationMention(event as Event<1>, viewerPubkey); } } -async function toNotificationMention(event: Event<1>) { - const status = await toStatus(event); +async function toNotificationMention(event: Event<1>, viewerPubkey?: string) { + const status = await toStatus(event, viewerPubkey); if (!status) return; return {