diff --git a/src/controllers/api/reports.ts b/src/controllers/api/reports.ts index 998054a..eb85bd2 100644 --- a/src/controllers/api/reports.ts +++ b/src/controllers/api/reports.ts @@ -33,11 +33,6 @@ const reportController: AppController = async (c) => { category, } = result.data; - const [profile] = await store.query([{ kinds: [0], authors: [account_id] }]); - if (profile) { - await hydrateEvents({ events: [profile], storage: store }); - } - const tags = [ ['p', account_id, category], ['P', Conf.pubkey], @@ -53,7 +48,8 @@ const reportController: AppController = async (c) => { tags, }, c); - return c.json(await renderReport(event, profile)); + await hydrateEvents({ events: [event], storage: store }); + return c.json(await renderReport(event)); }; /** https://docs.joinmastodon.org/methods/admin/reports/#get */ @@ -113,7 +109,7 @@ const adminReportResolveController: AppController = async (c) => { content: 'Report closed.', }, c); - return c.json(await renderAdminReport(event, { viewerPubkey: pubkey, action_taken: true })); + return c.json(await renderAdminReport(event, { viewerPubkey: pubkey, actionTaken: true })); }; export { adminReportController, adminReportResolveController, adminReportsController, reportController }; diff --git a/src/views/mastodon/reports.ts b/src/views/mastodon/reports.ts index 9592307..488f7b9 100644 --- a/src/views/mastodon/reports.ts +++ b/src/views/mastodon/reports.ts @@ -5,26 +5,24 @@ import { renderAdminAccount } from '@/views/mastodon/admin-accounts.ts'; import { renderStatus } from '@/views/mastodon/statuses.ts'; /** Expects a `reportEvent` of kind 1984 and a `profile` of kind 0 of the person being reported */ -async function renderReport(reportEvent: DittoEvent, profile: DittoEvent) { +async function renderReport(event: DittoEvent) { // The category is present in both the 'e' and 'p' tag, however, it is possible to report a user without reporting a note, so it's better to get the category from the 'p' tag - const category = reportEvent.tags.find(([name]) => name === 'p')?.[2]; - - const statusIds = reportEvent.tags.filter(([name]) => name === 'e').map((tag) => tag[1]) ?? []; - - const reportedPubkey = reportEvent.tags.find(([name]) => name === 'p')?.[1]; + const category = event.tags.find(([name]) => name === 'p')?.[2]; + const statusIds = event.tags.filter(([name]) => name === 'e').map((tag) => tag[1]) ?? []; + const reportedPubkey = event.tags.find(([name]) => name === 'p')?.[1]; if (!reportedPubkey) return; return { - id: reportEvent.id, + id: event.id, action_taken: false, action_taken_at: null, category, - comment: reportEvent.content, + comment: event.content, forwarded: false, - created_at: nostrDate(reportEvent.created_at).toISOString(), + created_at: nostrDate(event.created_at).toISOString(), status_ids: statusIds, rules_ids: null, - target_account: profile ? await renderAccount(profile) : await accountFromPubkey(reportedPubkey), + target_account: event.author ? await renderAccount(event.author) : await accountFromPubkey(reportedPubkey), }; }