]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/validators/shared/abuses.ts
Add ability to list imports of a channel sync
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / shared / abuses.ts
... / ...
CommitLineData
1import { Response } from 'express'
2import { AbuseModel } from '@server/models/abuse/abuse'
3import { HttpStatusCode } from '@shared/models'
4
5async 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
23export {
24 doesAbuseExist
25}