diff options
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/remote/videos.js | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/server/helpers/custom-validators/remote/videos.js b/server/helpers/custom-validators/remote/videos.js index 7c27b9dbb..ee68ebc10 100644 --- a/server/helpers/custom-validators/remote/videos.js +++ b/server/helpers/custom-validators/remote/videos.js | |||
@@ -1,8 +1,11 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const constants = require('../../../initializers/constants') | ||
3 | const videosValidators = require('../videos') | 4 | const videosValidators = require('../videos') |
4 | const miscValidators = require('../misc') | 5 | const miscValidators = require('../misc') |
5 | 6 | ||
7 | const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] | ||
8 | |||
6 | const remoteVideosValidators = { | 9 | const remoteVideosValidators = { |
7 | isEachRemoteRequestVideosValid | 10 | isEachRemoteRequestVideosValid |
8 | } | 11 | } |
@@ -13,29 +16,13 @@ function isEachRemoteRequestVideosValid (requests) { | |||
13 | const video = request.data | 16 | const video = request.data |
14 | return ( | 17 | return ( |
15 | isRequestTypeAddValid(request.type) && | 18 | isRequestTypeAddValid(request.type) && |
19 | isCommonVideoAttrbiutesValid(video) && | ||
16 | videosValidators.isVideoAuthorValid(video.author) && | 20 | videosValidators.isVideoAuthorValid(video.author) && |
17 | videosValidators.isVideoDateValid(video.createdAt) && | 21 | videosValidators.isVideoThumbnailDataValid(video.thumbnailData) |
18 | videosValidators.isVideoDateValid(video.updatedAt) && | ||
19 | videosValidators.isVideoDescriptionValid(video.description) && | ||
20 | videosValidators.isVideoDurationValid(video.duration) && | ||
21 | videosValidators.isVideoInfoHashValid(video.infoHash) && | ||
22 | videosValidators.isVideoNameValid(video.name) && | ||
23 | videosValidators.isVideoTagsValid(video.tags) && | ||
24 | videosValidators.isVideoThumbnailDataValid(video.thumbnailData) && | ||
25 | videosValidators.isVideoRemoteIdValid(video.remoteId) && | ||
26 | videosValidators.isVideoExtnameValid(video.extname) | ||
27 | ) || | 22 | ) || |
28 | ( | 23 | ( |
29 | isRequestTypeUpdateValid(request.type) && | 24 | isRequestTypeUpdateValid(request.type) && |
30 | videosValidators.isVideoDateValid(video.createdAt) && | 25 | isCommonVideoAttrbiutesValid(video) |
31 | videosValidators.isVideoDateValid(video.updatedAt) && | ||
32 | videosValidators.isVideoDescriptionValid(video.description) && | ||
33 | videosValidators.isVideoDurationValid(video.duration) && | ||
34 | videosValidators.isVideoInfoHashValid(video.infoHash) && | ||
35 | videosValidators.isVideoNameValid(video.name) && | ||
36 | videosValidators.isVideoTagsValid(video.tags) && | ||
37 | videosValidators.isVideoRemoteIdValid(video.remoteId) && | ||
38 | videosValidators.isVideoExtnameValid(video.extname) | ||
39 | ) || | 26 | ) || |
40 | ( | 27 | ( |
41 | isRequestTypeRemoveValid(request.type) && | 28 | isRequestTypeRemoveValid(request.type) && |
@@ -56,18 +43,30 @@ module.exports = remoteVideosValidators | |||
56 | 43 | ||
57 | // --------------------------------------------------------------------------- | 44 | // --------------------------------------------------------------------------- |
58 | 45 | ||
46 | function isCommonVideoAttrbiutesValid (video) { | ||
47 | return videosValidators.isVideoDateValid(video.createdAt) && | ||
48 | videosValidators.isVideoDateValid(video.updatedAt) && | ||
49 | videosValidators.isVideoDescriptionValid(video.description) && | ||
50 | videosValidators.isVideoDurationValid(video.duration) && | ||
51 | videosValidators.isVideoInfoHashValid(video.infoHash) && | ||
52 | videosValidators.isVideoNameValid(video.name) && | ||
53 | videosValidators.isVideoTagsValid(video.tags) && | ||
54 | videosValidators.isVideoRemoteIdValid(video.remoteId) && | ||
55 | videosValidators.isVideoExtnameValid(video.extname) | ||
56 | } | ||
57 | |||
59 | function isRequestTypeAddValid (value) { | 58 | function isRequestTypeAddValid (value) { |
60 | return value === 'add' | 59 | return value === ENDPOINT_ACTIONS.ADD |
61 | } | 60 | } |
62 | 61 | ||
63 | function isRequestTypeUpdateValid (value) { | 62 | function isRequestTypeUpdateValid (value) { |
64 | return value === 'update' | 63 | return value === ENDPOINT_ACTIONS.UPDATE |
65 | } | 64 | } |
66 | 65 | ||
67 | function isRequestTypeRemoveValid (value) { | 66 | function isRequestTypeRemoveValid (value) { |
68 | return value === 'remove' | 67 | return value === ENDPOINT_ACTIONS.REMOVE |
69 | } | 68 | } |
70 | 69 | ||
71 | function isRequestTypeReportAbuseValid (value) { | 70 | function isRequestTypeReportAbuseValid (value) { |
72 | return value === 'report-abuse' | 71 | return value === ENDPOINT_ACTIONS.REPORT_ABUSE |
73 | } | 72 | } |