feat: implement report resolve

This commit is contained in:
P. Reis
2024-05-07 20:49:42 -03:00
parent 66bae5eea7
commit 57495dbd7a
3 changed files with 45 additions and 5 deletions

View File

@@ -30,13 +30,14 @@ async function renderReport(reportEvent: DittoEvent, profile: DittoEvent) {
interface RenderAdminReportOpts {
viewerPubkey?: string;
action_taken?: boolean;
}
/** Admin-level information about a filed report.
* Expects an event of kind 1984 fully hydrated.
* https://docs.joinmastodon.org/entities/Admin_Report */
async function renderAdminReport(reportEvent: DittoEvent, opts: RenderAdminReportOpts) {
const { viewerPubkey } = opts;
const { viewerPubkey, action_taken = false } = opts;
// 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];
@@ -50,7 +51,7 @@ async function renderAdminReport(reportEvent: DittoEvent, opts: RenderAdminRepor
return {
id: reportEvent.id,
action_taken: false,
action_taken,
action_taken_at: null,
category,
comment: reportEvent.content,