]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/abuses.ts
Prevent caption listing of private videos
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / abuses.ts
index 0ca06a2522df7124f1288219860b6e9a215f04ed..94719641abd7561ff6414c43c31c58d304d0e7ed 100644 (file)
@@ -1,9 +1,11 @@
 import validator from 'validator'
-import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, AbuseVideoIs, AbuseCreate } from '@shared/models'
+import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
+import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@shared/models'
 import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
 import { exists, isArray } from './misc'
 
 const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES
+const ABUSE_MESSAGES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSE_MESSAGES
 
 function isAbuseReasonValid (value: string) {
   return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON)
@@ -46,13 +48,18 @@ function isAbuseVideoIsValid (value: AbuseVideoIs) {
   )
 }
 
+function isAbuseMessageValid (value: string) {
+  return exists(value) && validator.isLength(value, ABUSE_MESSAGES_CONSTRAINTS_FIELDS.MESSAGE)
+}
+
 // ---------------------------------------------------------------------------
 
 export {
   isAbuseReasonValid,
   isAbuseFilterValid,
   isAbusePredefinedReasonValid,
-  areAbusePredefinedReasonsValid as isAbusePredefinedReasonsValid,
+  isAbuseMessageValid,
+  areAbusePredefinedReasonsValid,
   isAbuseTimestampValid,
   isAbuseTimestampCoherent,
   isAbuseModerationCommentValid,