diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-23 10:40:39 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 3e753302d8c911b59971c16a8018df0e1ab78465 (patch) | |
tree | efce7ece3273589228c5c948ea6757b2bdf65429 /server/helpers/middlewares/video-channels.ts | |
parent | a8b666e9f1ed002230869606308749614390c82f (diff) | |
download | PeerTube-3e753302d8c911b59971c16a8018df0e1ab78465.tar.gz PeerTube-3e753302d8c911b59971c16a8018df0e1ab78465.tar.zst PeerTube-3e753302d8c911b59971c16a8018df0e1ab78465.zip |
Refactor middleware helpers
Diffstat (limited to 'server/helpers/middlewares/video-channels.ts')
-rw-r--r-- | server/helpers/middlewares/video-channels.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/server/helpers/middlewares/video-channels.ts b/server/helpers/middlewares/video-channels.ts new file mode 100644 index 000000000..1b573ca37 --- /dev/null +++ b/server/helpers/middlewares/video-channels.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { Response } from 'express' | ||
2 | import { VideoAbuseModel } from '../../models/video/video-abuse' | ||
3 | |||
4 | async function doesVideoAbuseExist (abuseId: number, videoId: number, res: Response) { | ||
5 | const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId) | ||
6 | |||
7 | if (videoAbuse === null) { | ||
8 | res.status(404) | ||
9 | .json({ error: 'Video abuse not found' }) | ||
10 | .end() | ||
11 | |||
12 | return false | ||
13 | } | ||
14 | |||
15 | res.locals.videoAbuse = videoAbuse | ||
16 | return true | ||
17 | } | ||
18 | |||
19 | // --------------------------------------------------------------------------- | ||
20 | |||
21 | export { | ||
22 | doesVideoAbuseExist | ||
23 | } | ||