aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/reqValidators/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-06 14:15:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-06 14:15:03 +0200
commitbe587647f98a4b83ca06a61fe55c7ac5d60927c6 (patch)
tree8a28a1cb9c9a06d80803ecd3fa00aa6767bb3f8b /server/middlewares/reqValidators/videos.js
parent8483b2216454afdb88f6aa53cad5eecd8c394bc0 (diff)
downloadPeerTube-be587647f98a4b83ca06a61fe55c7ac5d60927c6.tar.gz
PeerTube-be587647f98a4b83ca06a61fe55c7ac5d60927c6.tar.zst
PeerTube-be587647f98a4b83ca06a61fe55c7ac5d60927c6.zip
Add tags support to server
Diffstat (limited to 'server/middlewares/reqValidators/videos.js')
-rw-r--r--server/middlewares/reqValidators/videos.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/middlewares/reqValidators/videos.js b/server/middlewares/reqValidators/videos.js
index 10b6d39c6..3618e4716 100644
--- a/server/middlewares/reqValidators/videos.js
+++ b/server/middlewares/reqValidators/videos.js
@@ -2,6 +2,7 @@
2 2
3const checkErrors = require('./utils').checkErrors 3const checkErrors = require('./utils').checkErrors
4const constants = require('../../initializers/constants') 4const constants = require('../../initializers/constants')
5const customValidators = require('../../helpers/customValidators')
5const logger = require('../../helpers/logger') 6const logger = require('../../helpers/logger')
6const videos = require('../../lib/videos') 7const videos = require('../../lib/videos')
7const Videos = require('../../models/videos') 8const Videos = require('../../models/videos')
@@ -16,8 +17,9 @@ const reqValidatorsVideos = {
16function videosAdd (req, res, next) { 17function videosAdd (req, res, next) {
17 req.checkFiles('videofile[0].originalname', 'Should have an input video').notEmpty() 18 req.checkFiles('videofile[0].originalname', 'Should have an input video').notEmpty()
18 req.checkFiles('videofile[0].mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i) 19 req.checkFiles('videofile[0].mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i)
19 req.checkBody('name', 'Should have a name').isLength(1, 50) 20 req.checkBody('name', 'Should have a valid name').isVideoNameValid()
20 req.checkBody('description', 'Should have a description').isLength(1, 250) 21 req.checkBody('description', 'Should have a valid description').isVideoDescriptionValid()
22 req.checkBody('tags', 'Should have correct tags').isVideoTagsValid()
21 23
22 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) 24 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
23 25
@@ -29,7 +31,7 @@ function videosAdd (req, res, next) {
29 return res.status(400).send('Cannot retrieve metadata of the file.') 31 return res.status(400).send('Cannot retrieve metadata of the file.')
30 } 32 }
31 33
32 if (duration > constants.MAXIMUM_VIDEO_DURATION) { 34 if (!customValidators.isVideoDurationValid(duration)) {
33 return res.status(400).send('Duration of the video file is too big (max: ' + constants.MAXIMUM_VIDEO_DURATION + 's).') 35 return res.status(400).send('Duration of the video file is too big (max: ' + constants.MAXIMUM_VIDEO_DURATION + 's).')
34 } 36 }
35 37
@@ -48,7 +50,7 @@ function videosGet (req, res, next) {
48 Videos.get(req.params.id, function (err, video) { 50 Videos.get(req.params.id, function (err, video) {
49 if (err) { 51 if (err) {
50 logger.error('Error in videosGet request validator.', { error: err }) 52 logger.error('Error in videosGet request validator.', { error: err })
51 res.sendStatus(500) 53 return res.sendStatus(500)
52 } 54 }
53 55
54 const state = videos.getVideoState(video) 56 const state = videos.getVideoState(video)
@@ -68,7 +70,7 @@ function videosRemove (req, res, next) {
68 Videos.get(req.params.id, function (err, video) { 70 Videos.get(req.params.id, function (err, video) {
69 if (err) { 71 if (err) {
70 logger.error('Error in videosRemove request validator.', { error: err }) 72 logger.error('Error in videosRemove request validator.', { error: err })
71 res.sendStatus(500) 73 return res.sendStatus(500)
72 } 74 }
73 75
74 const state = videos.getVideoState(video) 76 const state = videos.getVideoState(video)
@@ -82,7 +84,7 @@ function videosRemove (req, res, next) {
82 84
83function videosSearch (req, res, next) { 85function videosSearch (req, res, next) {
84 const searchableColumns = constants.SEARCHABLE_COLUMNS.VIDEOS 86 const searchableColumns = constants.SEARCHABLE_COLUMNS.VIDEOS
85 req.checkParams('value', 'Should have a name').notEmpty() 87 req.checkParams('value', 'Should have a valid search').notEmpty()
86 req.checkQuery('field', 'Should have correct searchable column').optional().isIn(searchableColumns) 88 req.checkQuery('field', 'Should have correct searchable column').optional().isIn(searchableColumns)
87 89
88 logger.debug('Checking videosSearch parameters', { parameters: req.params }) 90 logger.debug('Checking videosSearch parameters', { parameters: req.params })