X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-blacklist.ts;h=34fcec38e341ee1584836c21c6b48860fc274f67;hb=a66c2e3252d6cca8958959966f42494ded564023;hp=25f90822847fda52028ece9d19b498b4f9a66493;hpb=0f6acda11681de90d38dd18669863c6e270851ee;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..34fcec38e 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts @@ -1,7 +1,7 @@ -import { Response } from 'express' -import * as validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../initializers' -import { VideoBlacklistModel } from '../../models/video/video-blacklist' +import validator from 'validator' +import { exists } from './misc' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' +import { VideoBlacklistType } from '../../../shared/models/videos' const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST @@ -9,24 +9,14 @@ function isVideoBlacklistReasonValid (value: string) { return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON) } -async function doesVideoBlacklistExist (videoId: number, res: Response) { - const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) - - if (videoBlacklist === null) { - res.status(404) - .json({ error: 'Blacklisted video not found' }) - .end() - - return false - } - - res.locals.videoBlacklist = videoBlacklist - return true +function isVideoBlacklistTypeValid (value: any) { + return exists(value) && + (value === VideoBlacklistType.AUTO_BEFORE_PUBLISHED || value === VideoBlacklistType.MANUAL) } // --------------------------------------------------------------------------- export { isVideoBlacklistReasonValid, - doesVideoBlacklistExist + isVideoBlacklistTypeValid }