]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/video-blacklist.ts
add quarantine videos feature (#1637)
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-blacklist.ts
index 25f90822847fda52028ece9d19b498b4f9a66493..465f58a9c02c088e57c28fb842b32e0c4ae14e96 100644 (file)
@@ -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
 }