diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/videos.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 7f727854d..e2d2c8e6d 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js | |||
@@ -21,7 +21,8 @@ const videosValidators = { | |||
21 | isVideoExtnameValid, | 21 | isVideoExtnameValid, |
22 | isVideoRemoteIdValid, | 22 | isVideoRemoteIdValid, |
23 | isVideoAbuseReasonValid, | 23 | isVideoAbuseReasonValid, |
24 | isVideoAbuseReporterUsernameValid | 24 | isVideoAbuseReporterUsernameValid, |
25 | isVideoFile | ||
25 | } | 26 | } |
26 | 27 | ||
27 | function isVideoAuthorValid (value) { | 28 | function isVideoAuthorValid (value) { |
@@ -81,6 +82,21 @@ function isVideoAbuseReporterUsernameValid (value) { | |||
81 | return usersValidators.isUserUsernameValid(value) | 82 | return usersValidators.isUserUsernameValid(value) |
82 | } | 83 | } |
83 | 84 | ||
85 | function isVideoFile (value, files) { | ||
86 | // Should have files | ||
87 | if (!files) return false | ||
88 | |||
89 | // Should have videofile file | ||
90 | const videofile = files.videofile | ||
91 | if (!videofile || videofile.length === 0) return false | ||
92 | |||
93 | // The file should exist | ||
94 | const file = videofile[0] | ||
95 | if (!file || !file.originalname) return false | ||
96 | |||
97 | return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype) | ||
98 | } | ||
99 | |||
84 | // --------------------------------------------------------------------------- | 100 | // --------------------------------------------------------------------------- |
85 | 101 | ||
86 | module.exports = videosValidators | 102 | module.exports = videosValidators |