]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/shared/abuses.ts
Refactor sort middlewares
[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
5 async function doesAbuseExist (abuseId: number | string, res: Response) {
6 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
7
8 if (!abuse) {
9 res.fail({
10 status: HttpStatusCode.NOT_FOUND_404,
11 message: 'Abuse not found'
12 })
13
14 return false
15 }
16
17 res.locals.abuse = abuse
18 return true
19 }
20
21 // ---------------------------------------------------------------------------
22
23 export {
24 doesAbuseExist
25 }