diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-27 11:40:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | 94148c9028829b5576a5dcbfba2c7fb9cf6443d3 (patch) | |
tree | 2774f272329111abd03e8441ff936da11fb1a3f3 /server/middlewares | |
parent | 441e453ae53e491b09c9b09b00b041788176ce64 (diff) | |
download | PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.tar.gz PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.tar.zst PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.zip |
Add abuse messages management in my account
Diffstat (limited to 'server/middlewares')
-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, |