X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-blacklist.ts;h=465f58a9c02c088e57c28fb842b32e0c4ae14e96;hb=7ccddd7b5250bd25a917a6e77e58b87b9484a2a4;hp=25f90822847fda52028ece9d19b498b4f9a66493;hpb=12fed49ebab0c414713d57ea316b6488ae6bef99;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index 25f908228..465f58a9c 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts @@ -1,7 +1,9 @@ import { Response } from 'express' import * as validator from 'validator' +import { exists } from './misc' import { CONSTRAINTS_FIELDS } from '../../initializers' import { VideoBlacklistModel } from '../../models/video/video-blacklist' +import { VideoBlacklistType } from '../../../shared/models/videos' const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST @@ -24,9 +26,14 @@ async function doesVideoBlacklistExist (videoId: number, res: Response) { return true } +function isVideoBlacklistTypeValid (value: any) { + return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined +} + // --------------------------------------------------------------------------- export { isVideoBlacklistReasonValid, + isVideoBlacklistTypeValid, doesVideoBlacklistExist }