]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/video-blacklist.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-blacklist.ts
index 3743f70233cb2507036efbc13adc50f1dbcbbaf4..34fcec38e341ee1584836c21c6b48860fc274f67 100644 (file)
@@ -1,8 +1,6 @@
-import { Response } from 'express'
-import * as validator from 'validator'
+import validator from 'validator'
 import { exists } from './misc'
 import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import { VideoBlacklistModel } from '../../models/video/video-blacklist'
 import { VideoBlacklistType } from '../../../shared/models/videos'
 
 const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST
@@ -11,29 +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) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined
+  return exists(value) &&
+    (value === VideoBlacklistType.AUTO_BEFORE_PUBLISHED || value === VideoBlacklistType.MANUAL)
 }
 
 // ---------------------------------------------------------------------------
 
 export {
   isVideoBlacklistReasonValid,
-  isVideoBlacklistTypeValid,
-  doesVideoBlacklistExist
+  isVideoBlacklistTypeValid
 }