From 226c356646e1563f5cf3718af1b64dddd8417a5b Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 2 May 2024 16:03:59 -0300 Subject: [PATCH] feat: create mastodon response for reports --- src/views/mastodon/reports.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/views/mastodon/reports.ts diff --git a/src/views/mastodon/reports.ts b/src/views/mastodon/reports.ts new file mode 100644 index 00000000..67f9f6da --- /dev/null +++ b/src/views/mastodon/reports.ts @@ -0,0 +1,33 @@ +import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; +import { renderAccount } from '@/views/mastodon/accounts.ts'; +import { nostrDate } from '@/utils.ts'; + +interface reportsOpts { + viewerPubkey?: string; +} + +/** Expects a `reportEvent` of kind 1984 and a `targetAccout` of kind 0 of the person being reported */ +async function renderReports(reportEvent: DittoEvent, targetAccout: DittoEvent, _opts: reportsOpts) { + const { + account_id, + status_ids, + comment, + forward, + category, + } = JSON.parse(reportEvent.content); + + return { + id: account_id, + action_taken: false, + action_taken_at: null, + category, + comment, + forwarded: forward, + created_at: nostrDate(reportEvent.created_at).toISOString(), + status_ids, + rules_ids: null, + target_account: await renderAccount(targetAccout), + }; +} + +export { renderReports };