]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/shared/abuses.ts
Don't inject untrusted input
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / shared / abuses.ts
1 import { Response } from 'express'
2 import { AbuseModel } from '@server/models/abuse/abuse'
3 import { HttpStatusCode } from '@shared/models'
4 import { forceNumber } from '@shared/core-utils'
5
6 async function doesAbuseExist (abuseId: number | string, res: Response) {
7 const abuse = await AbuseModel.loadByIdWithReporter(forceNumber(abuseId))
8
9 if (!abuse) {
10 res.fail({
11 status: HttpStatusCode.NOT_FOUND_404,
12 message: 'Abuse not found'
13 })
14
15 return false
16 }
17
18 res.locals.abuse = abuse
19 return true
20 }
21
22 // ---------------------------------------------------------------------------
23
24 export {
25 doesAbuseExist
26 }