From f99958c40e8b755c83dc27ac8f421bd38853c66c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 8 May 2024 14:59:30 -0500 Subject: [PATCH] reportsController -> reportController --- src/app.ts | 4 ++-- src/controllers/api/reports.ts | 8 ++++---- src/views/mastodon/reports.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app.ts b/src/app.ts index a3f6a43..5982165 100644 --- a/src/app.ts +++ b/src/app.ts @@ -48,7 +48,7 @@ import { adminReportController, adminReportResolveController, adminReportsController, - reportsController, + reportController, } from '@/controllers/api/reports.ts'; import { searchController } from '@/controllers/api/search.ts'; import { @@ -212,7 +212,7 @@ app.delete('/api/v1/pleroma/admin/statuses/:id', requireRole('admin'), pleromaAd app.get('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController); app.put('/api/v1/admin/ditto/relays', requireRole('admin'), adminSetRelaysController); -app.post('/api/v1/reports', requirePubkey, reportsController); +app.post('/api/v1/reports', requirePubkey, reportController); app.get('/api/v1/admin/reports', requirePubkey, requireRole('admin'), adminReportsController); app.get('/api/v1/admin/reports/:id{[0-9a-f]{64}}', requirePubkey, requireRole('admin'), adminReportController); app.post( diff --git a/src/controllers/api/reports.ts b/src/controllers/api/reports.ts index 24e314d..998054a 100644 --- a/src/controllers/api/reports.ts +++ b/src/controllers/api/reports.ts @@ -8,7 +8,7 @@ import { hydrateEvents } from '@/storages/hydrate.ts'; import { renderAdminReport } from '@/views/mastodon/reports.ts'; import { renderReport } from '@/views/mastodon/reports.ts'; -const reportsSchema = z.object({ +const reportSchema = z.object({ account_id: n.id(), status_ids: n.id().array().default([]), comment: z.string().max(1000).default(''), @@ -17,10 +17,10 @@ const reportsSchema = z.object({ }); /** https://docs.joinmastodon.org/methods/reports/#post */ -const reportsController: AppController = async (c) => { +const reportController: AppController = async (c) => { const store = c.get('store'); const body = await parseBody(c.req.raw); - const result = reportsSchema.safeParse(body); + const result = reportSchema.safeParse(body); if (!result.success) { return c.json(result.error, 422); @@ -116,4 +116,4 @@ const adminReportResolveController: AppController = async (c) => { return c.json(await renderAdminReport(event, { viewerPubkey: pubkey, action_taken: true })); }; -export { adminReportController, adminReportResolveController, adminReportsController, reportsController }; +export { adminReportController, adminReportResolveController, adminReportsController, reportController }; diff --git a/src/views/mastodon/reports.ts b/src/views/mastodon/reports.ts index 5ddbe69..9592307 100644 --- a/src/views/mastodon/reports.ts +++ b/src/views/mastodon/reports.ts @@ -30,14 +30,14 @@ async function renderReport(reportEvent: DittoEvent, profile: DittoEvent) { interface RenderAdminReportOpts { viewerPubkey?: string; - action_taken?: boolean; + actionTaken?: 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, action_taken = false } = opts; + const { viewerPubkey, actionTaken = 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]; @@ -51,7 +51,7 @@ async function renderAdminReport(reportEvent: DittoEvent, opts: RenderAdminRepor return { id: reportEvent.id, - action_taken, + action_taken: actionTaken, action_taken_at: null, category, comment: reportEvent.content,