]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/middlewares/abuses.ts
Fix video update
[github/Chocobozzz/PeerTube.git] / server / helpers / middlewares / abuses.ts
... / ...
CommitLineData
1import { Response } from 'express'
2import { AbuseModel } from '../../models/abuse/abuse'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4
5async function doesAbuseExist (abuseId: number | string, res: Response) {
6 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
7
8 if (!abuse) {
9 res.status(HttpStatusCode.NOT_FOUND_404)
10 .json({ error: 'Abuse not found' })
11
12 return false
13 }
14
15 res.locals.abuse = abuse
16 return true
17}
18
19// ---------------------------------------------------------------------------
20
21export {
22 doesAbuseExist
23}