aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/videos.js19
-rw-r--r--server/helpers/logger.js6
2 files changed, 16 insertions, 9 deletions
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js
index 1a7753265..be8256a80 100644
--- a/server/helpers/custom-validators/videos.js
+++ b/server/helpers/custom-validators/videos.js
@@ -13,7 +13,7 @@ const videosValidators = {
13 isVideoDateValid, 13 isVideoDateValid,
14 isVideoDescriptionValid, 14 isVideoDescriptionValid,
15 isVideoDurationValid, 15 isVideoDurationValid,
16 isVideoMagnetValid, 16 isVideoInfoHashValid,
17 isVideoNameValid, 17 isVideoNameValid,
18 isVideoPodHostValid, 18 isVideoPodHostValid,
19 isVideoTagsValid, 19 isVideoTagsValid,
@@ -28,14 +28,15 @@ function isEachRemoteVideosValid (requests) {
28 return ( 28 return (
29 isRequestTypeAddValid(request.type) && 29 isRequestTypeAddValid(request.type) &&
30 isVideoAuthorValid(video.author) && 30 isVideoAuthorValid(video.author) &&
31 isVideoDateValid(video.createdDate) && 31 isVideoDateValid(video.createdAt) &&
32 isVideoDescriptionValid(video.description) && 32 isVideoDescriptionValid(video.description) &&
33 isVideoDurationValid(video.duration) && 33 isVideoDurationValid(video.duration) &&
34 isVideoMagnetValid(video.magnet) && 34 isVideoInfoHashValid(video.infoHash) &&
35 isVideoNameValid(video.name) && 35 isVideoNameValid(video.name) &&
36 isVideoTagsValid(video.tags) && 36 isVideoTagsValid(video.tags) &&
37 isVideoThumbnail64Valid(video.thumbnailBase64) && 37 isVideoThumbnail64Valid(video.thumbnailBase64) &&
38 isVideoRemoteIdValid(video.remoteId) 38 isVideoRemoteIdValid(video.remoteId) &&
39 isVideoExtnameValid(video.extname)
39 ) || 40 ) ||
40 ( 41 (
41 isRequestTypeRemoveValid(request.type) && 42 isRequestTypeRemoveValid(request.type) &&
@@ -61,8 +62,12 @@ function isVideoDurationValid (value) {
61 return validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) 62 return validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION)
62} 63}
63 64
64function isVideoMagnetValid (value) { 65function isVideoExtnameValid (value) {
65 return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.INFO_HASH) 66 return VIDEOS_CONSTRAINTS_FIELDS.EXTNAME.indexOf(value) !== -1
67}
68
69function isVideoInfoHashValid (value) {
70 return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
66} 71}
67 72
68function isVideoNameValid (value) { 73function isVideoNameValid (value) {
@@ -93,7 +98,7 @@ function isVideoThumbnail64Valid (value) {
93} 98}
94 99
95function isVideoRemoteIdValid (value) { 100function isVideoRemoteIdValid (value) {
96 return validator.isMongoId(value) 101 return validator.isUUID(value, 4)
97} 102}
98 103
99// --------------------------------------------------------------------------- 104// ---------------------------------------------------------------------------
diff --git a/server/helpers/logger.js b/server/helpers/logger.js
index fcc1789fd..281acedb8 100644
--- a/server/helpers/logger.js
+++ b/server/helpers/logger.js
@@ -22,7 +22,8 @@ const logger = new winston.Logger({
22 json: true, 22 json: true,
23 maxsize: 5242880, 23 maxsize: 5242880,
24 maxFiles: 5, 24 maxFiles: 5,
25 colorize: false 25 colorize: false,
26 prettyPrint: true
26 }), 27 }),
27 new winston.transports.Console({ 28 new winston.transports.Console({
28 level: 'debug', 29 level: 'debug',
@@ -30,7 +31,8 @@ const logger = new winston.Logger({
30 handleExceptions: true, 31 handleExceptions: true,
31 humanReadableUnhandledException: true, 32 humanReadableUnhandledException: true,
32 json: false, 33 json: false,
33 colorize: true 34 colorize: true,
35 prettyPrint: true
34 }) 36 })
35 ], 37 ],
36 exitOnError: true 38 exitOnError: true