feat: create mastodon response for reports

This commit is contained in:
P. Reis 2024-05-02 16:03:59 -03:00
parent 23f8377231
commit 226c356646
1 changed files with 33 additions and 0 deletions

View File

@ -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 };