diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-02-10 11:27:14 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-02-10 11:27:14 +0100 |
commit | f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e (patch) | |
tree | df99579a701d40b02e495c76337a6d266f60dcc6 /server/helpers | |
parent | c70e0710b39b45e1b8b2d043e3d94f59df16b8a8 (diff) | |
download | PeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.tar.gz PeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.tar.zst PeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.zip |
Server: update express-validator
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 |