From 94148c9028829b5576a5dcbfba2c7fb9cf6443d3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Jul 2020 11:40:30 +0200 Subject: Add abuse messages management in my account --- server/controllers/api/abuse.ts | 4 ++++ server/controllers/api/users/my-abuses.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts index 50d068157..72e62fc0b 100644 --- a/server/controllers/api/abuse.ts +++ b/server/controllers/api/abuse.ts @@ -16,6 +16,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, + checkAbuseValidForMessagesValidator, deleteAbuseMessageValidator, ensureUserHasRight, getAbuseValidator, @@ -58,12 +59,14 @@ abuseRouter.delete('/:id', abuseRouter.get('/:id/messages', authenticate, asyncMiddleware(getAbuseValidator), + checkAbuseValidForMessagesValidator, asyncRetryTransactionMiddleware(listAbuseMessages) ) abuseRouter.post('/:id/messages', authenticate, asyncMiddleware(getAbuseValidator), + checkAbuseValidForMessagesValidator, addAbuseMessageValidator, asyncRetryTransactionMiddleware(addAbuseMessage) ) @@ -71,6 +74,7 @@ abuseRouter.post('/:id/messages', abuseRouter.delete('/:id/messages/:messageId', authenticate, asyncMiddleware(getAbuseValidator), + checkAbuseValidForMessagesValidator, asyncMiddleware(deleteAbuseMessageValidator), asyncRetryTransactionMiddleware(deleteAbuseMessage) ) diff --git a/server/controllers/api/users/my-abuses.ts b/server/controllers/api/users/my-abuses.ts index e43fc483e..fcd0ce3fc 100644 --- a/server/controllers/api/users/my-abuses.ts +++ b/server/controllers/api/users/my-abuses.ts @@ -43,6 +43,6 @@ async function listMyAbuses (req: express.Request, res: express.Response) { return res.json({ total: resultList.total, - data: resultList.data.map(d => d.toFormattedAdminJSON()) + data: resultList.data.map(d => d.toFormattedUserJSON()) }) } -- cgit v1.2.3