]>
Commit | Line | Data |
---|---|---|
1 | import { Response } from 'express' | |
2 | import { VideoAbuseModel } from '../../models/video/video-abuse' | |
3 | ||
4 | async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) { | |
5 | const abuseId = parseInt(abuseIdArg + '', 10) | |
6 | const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId) | |
7 | ||
8 | if (videoAbuse === null) { | |
9 | res.status(404) | |
10 | .json({ error: 'Video abuse not found' }) | |
11 | .end() | |
12 | ||
13 | return false | |
14 | } | |
15 | ||
16 | res.locals.videoAbuse = videoAbuse | |
17 | return true | |
18 | } | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | ||
22 | export { | |
23 | doesVideoAbuseExist | |
24 | } |