diff options
Diffstat (limited to 'server/helpers/custom-validators/video-blacklist.ts')
-rw-r--r-- | server/helpers/custom-validators/video-blacklist.ts | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index 3743f7023..9a44332ef 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts | |||
@@ -1,8 +1,6 @@ | |||
1 | import { Response } from 'express' | ||
2 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
3 | import { exists } from './misc' | 2 | import { exists } from './misc' |
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 3 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
5 | import { VideoBlacklistModel } from '../../models/video/video-blacklist' | ||
6 | import { VideoBlacklistType } from '../../../shared/models/videos' | 4 | import { VideoBlacklistType } from '../../../shared/models/videos' |
7 | 5 | ||
8 | const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST | 6 | const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST |
@@ -11,21 +9,6 @@ function isVideoBlacklistReasonValid (value: string) { | |||
11 | return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON) | 9 | return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON) |
12 | } | 10 | } |
13 | 11 | ||
14 | async function doesVideoBlacklistExist (videoId: number, res: Response) { | ||
15 | const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) | ||
16 | |||
17 | if (videoBlacklist === null) { | ||
18 | res.status(404) | ||
19 | .json({ error: 'Blacklisted video not found' }) | ||
20 | .end() | ||
21 | |||
22 | return false | ||
23 | } | ||
24 | |||
25 | res.locals.videoBlacklist = videoBlacklist | ||
26 | return true | ||
27 | } | ||
28 | |||
29 | function isVideoBlacklistTypeValid (value: any) { | 12 | function isVideoBlacklistTypeValid (value: any) { |
30 | return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined | 13 | return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined |
31 | } | 14 | } |
@@ -34,6 +17,5 @@ function isVideoBlacklistTypeValid (value: any) { | |||
34 | 17 | ||
35 | export { | 18 | export { |
36 | isVideoBlacklistReasonValid, | 19 | isVideoBlacklistReasonValid, |
37 | isVideoBlacklistTypeValid, | 20 | isVideoBlacklistTypeValid |
38 | doesVideoBlacklistExist | ||
39 | } | 21 | } |