diff options
Diffstat (limited to 'server/middlewares/validators/abuse.ts')
-rw-r--r-- | server/middlewares/validators/abuse.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts index cb0bc658a..2a096e0af 100644 --- a/server/middlewares/validators/abuse.ts +++ b/server/middlewares/validators/abuse.ts | |||
@@ -201,6 +201,21 @@ const getAbuseValidator = [ | |||
201 | } | 201 | } |
202 | ] | 202 | ] |
203 | 203 | ||
204 | const checkAbuseValidForMessagesValidator = [ | ||
205 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
206 | logger.debug('Checking checkAbuseValidForMessagesValidator parameters', { parameters: req.body }) | ||
207 | |||
208 | const abuse = res.locals.abuse | ||
209 | if (abuse.ReporterAccount.isOwned() === false) { | ||
210 | return res.status(400).json({ | ||
211 | error: 'This abuse was created by a user of your instance.', | ||
212 | }) | ||
213 | } | ||
214 | |||
215 | return next() | ||
216 | } | ||
217 | ] | ||
218 | |||
204 | const addAbuseMessageValidator = [ | 219 | const addAbuseMessageValidator = [ |
205 | body('message').custom(isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'), | 220 | body('message').custom(isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'), |
206 | 221 | ||
@@ -357,6 +372,7 @@ export { | |||
357 | abuseReportValidator, | 372 | abuseReportValidator, |
358 | abuseGetValidator, | 373 | abuseGetValidator, |
359 | addAbuseMessageValidator, | 374 | addAbuseMessageValidator, |
375 | checkAbuseValidForMessagesValidator, | ||
360 | abuseUpdateValidator, | 376 | abuseUpdateValidator, |
361 | deleteAbuseMessageValidator, | 377 | deleteAbuseMessageValidator, |
362 | abuseListForUserValidator, | 378 | abuseListForUserValidator, |