aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/middlewares/validators/abuse.ts66
-rw-r--r--server/middlewares/validators/account.ts6
-rw-r--r--server/middlewares/validators/activitypub/pagination.ts2
-rw-r--r--server/middlewares/validators/activitypub/signature.ts6
-rw-r--r--server/middlewares/validators/blocklist.ts18
-rw-r--r--server/middlewares/validators/bulk.ts5
-rw-r--r--server/middlewares/validators/config.ts186
-rw-r--r--server/middlewares/validators/feeds.ts30
-rw-r--r--server/middlewares/validators/follows.ts10
-rw-r--r--server/middlewares/validators/jobs.ts6
-rw-r--r--server/middlewares/validators/logs.ts14
-rw-r--r--server/middlewares/validators/metrics.ts17
-rw-r--r--server/middlewares/validators/oembed.ts15
-rw-r--r--server/middlewares/validators/pagination.ts2
-rw-r--r--server/middlewares/validators/plugins.ts37
-rw-r--r--server/middlewares/validators/redundancy.ts20
-rw-r--r--server/middlewares/validators/search.ts32
-rw-r--r--server/middlewares/validators/server.ts6
-rw-r--r--server/middlewares/validators/shared/utils.ts4
-rw-r--r--server/middlewares/validators/sort.ts4
-rw-r--r--server/middlewares/validators/themes.ts9
-rw-r--r--server/middlewares/validators/user-history.ts4
-rw-r--r--server/middlewares/validators/user-notifications.ts26
-rw-r--r--server/middlewares/validators/user-subscriptions.ts12
-rw-r--r--server/middlewares/validators/users.ts131
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts2
-rw-r--r--server/middlewares/validators/videos/video-captions.ts2
-rw-r--r--server/middlewares/validators/videos/video-channel-sync.ts7
-rw-r--r--server/middlewares/validators/videos/video-channels.ts38
-rw-r--r--server/middlewares/validators/videos/video-comments.ts35
-rw-r--r--server/middlewares/validators/videos/video-files.ts4
-rw-r--r--server/middlewares/validators/videos/video-imports.ts12
-rw-r--r--server/middlewares/validators/videos/video-live.ts14
-rw-r--r--server/middlewares/validators/videos/video-ownership-changes.ts2
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts35
-rw-r--r--server/middlewares/validators/videos/video-rates.ts13
-rw-r--r--server/middlewares/validators/videos/video-shares.ts2
-rw-r--r--server/middlewares/validators/videos/video-stats.ts15
-rw-r--r--server/middlewares/validators/videos/video-studio.ts6
-rw-r--r--server/middlewares/validators/videos/video-transcoding.ts2
-rw-r--r--server/middlewares/validators/videos/video-view.ts4
-rw-r--r--server/middlewares/validators/videos/videos.ts67
-rw-r--r--server/middlewares/validators/webfinger.ts3
43 files changed, 512 insertions, 419 deletions
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts
index 22f66c8cf..e4aa1a839 100644
--- a/server/middlewares/validators/abuse.ts
+++ b/server/middlewares/validators/abuse.ts
@@ -22,41 +22,34 @@ import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdE
22const abuseReportValidator = [ 22const abuseReportValidator = [
23 body('account.id') 23 body('account.id')
24 .optional() 24 .optional()
25 .custom(isIdValid) 25 .custom(isIdValid),
26 .withMessage('Should have a valid accountId'),
27 26
28 body('video.id') 27 body('video.id')
29 .optional() 28 .optional()
30 .customSanitizer(toCompleteUUID) 29 .customSanitizer(toCompleteUUID)
31 .custom(isIdOrUUIDValid) 30 .custom(isIdOrUUIDValid),
32 .withMessage('Should have a valid videoId'),
33 body('video.startAt') 31 body('video.startAt')
34 .optional() 32 .optional()
35 .customSanitizer(toIntOrNull) 33 .customSanitizer(toIntOrNull)
36 .custom(isAbuseTimestampValid) 34 .custom(isAbuseTimestampValid),
37 .withMessage('Should have valid starting time value'),
38 body('video.endAt') 35 body('video.endAt')
39 .optional() 36 .optional()
40 .customSanitizer(toIntOrNull) 37 .customSanitizer(toIntOrNull)
41 .custom(isAbuseTimestampValid) 38 .custom(isAbuseTimestampValid)
42 .withMessage('Should have valid ending time value')
43 .bail() 39 .bail()
44 .custom(isAbuseTimestampCoherent) 40 .custom(isAbuseTimestampCoherent)
45 .withMessage('Should have a startAt timestamp beginning before endAt'), 41 .withMessage('Should have a startAt timestamp beginning before endAt'),
46 42
47 body('comment.id') 43 body('comment.id')
48 .optional() 44 .optional()
49 .custom(isIdValid) 45 .custom(isIdValid),
50 .withMessage('Should have a valid commentId'),
51 46
52 body('reason') 47 body('reason')
53 .custom(isAbuseReasonValid) 48 .custom(isAbuseReasonValid),
54 .withMessage('Should have a valid reason'),
55 49
56 body('predefinedReasons') 50 body('predefinedReasons')
57 .optional() 51 .optional()
58 .custom(areAbusePredefinedReasonsValid) 52 .custom(areAbusePredefinedReasonsValid),
59 .withMessage('Should have a valid list of predefined reasons'),
60 53
61 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 54 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
62 logger.debug('Checking abuseReport parameters', { parameters: req.body }) 55 logger.debug('Checking abuseReport parameters', { parameters: req.body })
@@ -79,7 +72,8 @@ const abuseReportValidator = [
79] 72]
80 73
81const abuseGetValidator = [ 74const abuseGetValidator = [
82 param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'), 75 param('id')
76 .custom(isIdValid),
83 77
84 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 78 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
85 logger.debug('Checking abuseGetValidator parameters', { parameters: req.body }) 79 logger.debug('Checking abuseGetValidator parameters', { parameters: req.body })
@@ -92,14 +86,15 @@ const abuseGetValidator = [
92] 86]
93 87
94const abuseUpdateValidator = [ 88const abuseUpdateValidator = [
95 param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'), 89 param('id')
90 .custom(isIdValid),
96 91
97 body('state') 92 body('state')
98 .optional() 93 .optional()
99 .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'), 94 .custom(isAbuseStateValid),
100 body('moderationComment') 95 body('moderationComment')
101 .optional() 96 .optional()
102 .custom(isAbuseModerationCommentValid).withMessage('Should have a valid moderation comment'), 97 .custom(isAbuseModerationCommentValid),
103 98
104 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 99 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
105 logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body }) 100 logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body })
@@ -114,36 +109,34 @@ const abuseUpdateValidator = [
114const abuseListForAdminsValidator = [ 109const abuseListForAdminsValidator = [
115 query('id') 110 query('id')
116 .optional() 111 .optional()
117 .custom(isIdValid).withMessage('Should have a valid id'), 112 .custom(isIdValid),
118 query('filter') 113 query('filter')
119 .optional() 114 .optional()
120 .custom(isAbuseFilterValid) 115 .custom(isAbuseFilterValid),
121 .withMessage('Should have a valid filter'),
122 query('predefinedReason') 116 query('predefinedReason')
123 .optional() 117 .optional()
124 .custom(isAbusePredefinedReasonValid) 118 .custom(isAbusePredefinedReasonValid),
125 .withMessage('Should have a valid predefinedReason'),
126 query('search') 119 query('search')
127 .optional() 120 .optional()
128 .custom(exists).withMessage('Should have a valid search'), 121 .custom(exists),
129 query('state') 122 query('state')
130 .optional() 123 .optional()
131 .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'), 124 .custom(isAbuseStateValid),
132 query('videoIs') 125 query('videoIs')
133 .optional() 126 .optional()
134 .custom(isAbuseVideoIsValid).withMessage('Should have a valid "video is" attribute'), 127 .custom(isAbuseVideoIsValid),
135 query('searchReporter') 128 query('searchReporter')
136 .optional() 129 .optional()
137 .custom(exists).withMessage('Should have a valid reporter search'), 130 .custom(exists),
138 query('searchReportee') 131 query('searchReportee')
139 .optional() 132 .optional()
140 .custom(exists).withMessage('Should have a valid reportee search'), 133 .custom(exists),
141 query('searchVideo') 134 query('searchVideo')
142 .optional() 135 .optional()
143 .custom(exists).withMessage('Should have a valid video search'), 136 .custom(exists),
144 query('searchVideoChannel') 137 query('searchVideoChannel')
145 .optional() 138 .optional()
146 .custom(exists).withMessage('Should have a valid video channel search'), 139 .custom(exists),
147 140
148 (req: express.Request, res: express.Response, next: express.NextFunction) => { 141 (req: express.Request, res: express.Response, next: express.NextFunction) => {
149 logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body }) 142 logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body })
@@ -157,15 +150,15 @@ const abuseListForAdminsValidator = [
157const abuseListForUserValidator = [ 150const abuseListForUserValidator = [
158 query('id') 151 query('id')
159 .optional() 152 .optional()
160 .custom(isIdValid).withMessage('Should have a valid id'), 153 .custom(isIdValid),
161 154
162 query('search') 155 query('search')
163 .optional() 156 .optional()
164 .custom(exists).withMessage('Should have a valid search'), 157 .custom(exists),
165 158
166 query('state') 159 query('state')
167 .optional() 160 .optional()
168 .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'), 161 .custom(isAbuseStateValid),
169 162
170 (req: express.Request, res: express.Response, next: express.NextFunction) => { 163 (req: express.Request, res: express.Response, next: express.NextFunction) => {
171 logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body }) 164 logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body })
@@ -177,7 +170,8 @@ const abuseListForUserValidator = [
177] 170]
178 171
179const getAbuseValidator = [ 172const getAbuseValidator = [
180 param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'), 173 param('id')
174 .custom(isIdValid),
181 175
182 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 176 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
183 logger.debug('Checking getAbuseValidator parameters', { parameters: req.body }) 177 logger.debug('Checking getAbuseValidator parameters', { parameters: req.body })
@@ -216,7 +210,8 @@ const checkAbuseValidForMessagesValidator = [
216] 210]
217 211
218const addAbuseMessageValidator = [ 212const addAbuseMessageValidator = [
219 body('message').custom(isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'), 213 body('message')
214 .custom(isAbuseMessageValid),
220 215
221 (req: express.Request, res: express.Response, next: express.NextFunction) => { 216 (req: express.Request, res: express.Response, next: express.NextFunction) => {
222 logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body }) 217 logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body })
@@ -228,7 +223,8 @@ const addAbuseMessageValidator = [
228] 223]
229 224
230const deleteAbuseMessageValidator = [ 225const deleteAbuseMessageValidator = [
231 param('messageId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid message id'), 226 param('messageId')
227 .custom(isIdValid),
232 228
233 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 229 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
234 logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body }) 230 logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index e529c831d..a7534ced5 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -5,7 +5,8 @@ import { logger } from '../../helpers/logger'
5import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared' 5import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
6 6
7const localAccountValidator = [ 7const localAccountValidator = [
8 param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), 8 param('name')
9 .custom(isAccountNameValid),
9 10
10 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 11 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) 12 logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
@@ -18,7 +19,8 @@ const localAccountValidator = [
18] 19]
19 20
20const accountNameWithHostGetValidator = [ 21const accountNameWithHostGetValidator = [
21 param('accountName').exists().withMessage('Should have an account name with host'), 22 param('accountName')
23 .exists(),
22 24
23 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 25 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
24 logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params }) 26 logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/middlewares/validators/activitypub/pagination.ts
index c542d4173..69c4febaf 100644
--- a/server/middlewares/validators/activitypub/pagination.ts
+++ b/server/middlewares/validators/activitypub/pagination.ts
@@ -7,7 +7,7 @@ import { areValidationErrors } from '../shared'
7const apPaginationValidator = [ 7const apPaginationValidator = [
8 query('page') 8 query('page')
9 .optional() 9 .optional()
10 .isInt({ min: 1 }).withMessage('Should have a valid page number'), 10 .isInt({ min: 1 }),
11 query('size') 11 query('size')
12 .optional() 12 .optional()
13 .isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`), 13 .isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`),
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts
index 642bcefe0..8c133ecef 100644
--- a/server/middlewares/validators/activitypub/signature.ts
+++ b/server/middlewares/validators/activitypub/signature.ts
@@ -12,16 +12,16 @@ import { areValidationErrors } from '../shared'
12const signatureValidator = [ 12const signatureValidator = [
13 body('signature.type') 13 body('signature.type')
14 .optional() 14 .optional()
15 .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'), 15 .custom(isSignatureTypeValid),
16 body('signature.created') 16 body('signature.created')
17 .optional() 17 .optional()
18 .custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'), 18 .custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'),
19 body('signature.creator') 19 body('signature.creator')
20 .optional() 20 .optional()
21 .custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'), 21 .custom(isSignatureCreatorValid),
22 body('signature.signatureValue') 22 body('signature.signatureValue')
23 .optional() 23 .optional()
24 .custom(isSignatureValueValid).withMessage('Should have a valid signature value'), 24 .custom(isSignatureValueValid),
25 25
26 (req: express.Request, res: express.Response, next: express.NextFunction) => { 26 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } }) 27 logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } })
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 12980ced4..3de614522 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -13,7 +13,8 @@ import { ServerBlocklistModel } from '../../models/server/server-blocklist'
13import { areValidationErrors, doesAccountNameWithHostExist } from './shared' 13import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
14 14
15const blockAccountValidator = [ 15const blockAccountValidator = [
16 body('accountName').exists().withMessage('Should have an account name with host'), 16 body('accountName')
17 .exists(),
17 18
18 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 19 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body }) 20 logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })
@@ -37,7 +38,8 @@ const blockAccountValidator = [
37] 38]
38 39
39const unblockAccountByAccountValidator = [ 40const unblockAccountByAccountValidator = [
40 param('accountName').exists().withMessage('Should have an account name with host'), 41 param('accountName')
42 .exists(),
41 43
42 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 44 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
43 logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params }) 45 logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })
@@ -54,7 +56,8 @@ const unblockAccountByAccountValidator = [
54] 56]
55 57
56const unblockAccountByServerValidator = [ 58const unblockAccountByServerValidator = [
57 param('accountName').exists().withMessage('Should have an account name with host'), 59 param('accountName')
60 .exists(),
58 61
59 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 62 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
60 logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params }) 63 logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })
@@ -71,7 +74,8 @@ const unblockAccountByServerValidator = [
71] 74]
72 75
73const blockServerValidator = [ 76const blockServerValidator = [
74 body('host').custom(isHostValid).withMessage('Should have a valid host'), 77 body('host')
78 .custom(isHostValid),
75 79
76 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 80 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
77 logger.debug('Checking serverGetValidator parameters', { parameters: req.body }) 81 logger.debug('Checking serverGetValidator parameters', { parameters: req.body })
@@ -96,7 +100,8 @@ const blockServerValidator = [
96] 100]
97 101
98const unblockServerByAccountValidator = [ 102const unblockServerByAccountValidator = [
99 param('host').custom(isHostValid).withMessage('Should have an account name with host'), 103 param('host')
104 .custom(isHostValid),
100 105
101 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 106 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
102 logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params }) 107 logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params })
@@ -111,7 +116,8 @@ const unblockServerByAccountValidator = [
111] 116]
112 117
113const unblockServerByServerValidator = [ 118const unblockServerByServerValidator = [
114 param('host').custom(isHostValid).withMessage('Should have an account name with host'), 119 param('host')
120 .custom(isHostValid),
115 121
116 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 122 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
117 logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params }) 123 logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts
index 1cfc7481e..5bc15e076 100644
--- a/server/middlewares/validators/bulk.ts
+++ b/server/middlewares/validators/bulk.ts
@@ -7,9 +7,10 @@ import { logger } from '../../helpers/logger'
7import { areValidationErrors, doesAccountNameWithHostExist } from './shared' 7import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
8 8
9const bulkRemoveCommentsOfValidator = [ 9const bulkRemoveCommentsOfValidator = [
10 body('accountName').exists().withMessage('Should have an account name with host'), 10 body('accountName')
11 .exists(),
11 body('scope') 12 body('scope')
12 .custom(isBulkRemoveCommentsOfScopeValid).withMessage('Should have a valid scope'), 13 .custom(isBulkRemoveCommentsOfScopeValid),
13 14
14 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 15 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
15 logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body }) 16 logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index f60103f48..c89f3087e 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -11,100 +11,98 @@ import { areValidationErrors } from './shared'
11import { HttpStatusCode } from '@shared/models/http/http-error-codes' 11import { HttpStatusCode } from '@shared/models/http/http-error-codes'
12 12
13const customConfigUpdateValidator = [ 13const customConfigUpdateValidator = [
14 body('instance.name').exists().withMessage('Should have a valid instance name'), 14 body('instance.name').exists(),
15 body('instance.shortDescription').exists().withMessage('Should have a valid instance short description'), 15 body('instance.shortDescription').exists(),
16 body('instance.description').exists().withMessage('Should have a valid instance description'), 16 body('instance.description').exists(),
17 body('instance.terms').exists().withMessage('Should have a valid instance terms'), 17 body('instance.terms').exists(),
18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), 18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid),
19 body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), 19 body('instance.defaultClientRoute').exists(),
20 body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), 20 body('instance.customizations.css').exists(),
21 body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), 21 body('instance.customizations.javascript').exists(),
22 22
23 body('services.twitter.username').exists().withMessage('Should have a valid twitter username'), 23 body('services.twitter.username').exists(),
24 body('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'), 24 body('services.twitter.whitelisted').isBoolean(),
25 25
26 body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'), 26 body('cache.previews.size').isInt(),
27 body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'), 27 body('cache.captions.size').isInt(),
28 body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'), 28 body('cache.torrents.size').isInt(),
29 29
30 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), 30 body('signup.enabled').isBoolean(),
31 body('signup.limit').isInt().withMessage('Should have a valid signup limit'), 31 body('signup.limit').isInt(),
32 body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), 32 body('signup.requiresEmailVerification').isBoolean(),
33 body('signup.minimumAge').isInt().withMessage('Should have a valid minimum age required'), 33 body('signup.minimumAge').isInt(),
34 34
35 body('admin.email').isEmail().withMessage('Should have a valid administrator email'), 35 body('admin.email').isEmail(),
36 body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), 36 body('contactForm.enabled').isBoolean(),
37 37
38 body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), 38 body('user.videoQuota').custom(isUserVideoQuotaValid),
39 body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), 39 body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid),
40 40
41 body('videoChannels.maxPerUser').isInt().withMessage('Should have a valid maximum amount of video channels per user'), 41 body('videoChannels.maxPerUser').isInt(),
42 42
43 body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), 43 body('transcoding.enabled').isBoolean(),
44 body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), 44 body('transcoding.allowAdditionalExtensions').isBoolean(),
45 body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), 45 body('transcoding.threads').isInt(),
46 body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'), 46 body('transcoding.concurrency').isInt({ min: 1 }),
47 body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'), 47 body('transcoding.resolutions.0p').isBoolean(),
48 body('transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'), 48 body('transcoding.resolutions.144p').isBoolean(),
49 body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), 49 body('transcoding.resolutions.240p').isBoolean(),
50 body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), 50 body('transcoding.resolutions.360p').isBoolean(),
51 body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), 51 body('transcoding.resolutions.480p').isBoolean(),
52 body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), 52 body('transcoding.resolutions.720p').isBoolean(),
53 body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), 53 body('transcoding.resolutions.1080p').isBoolean(),
54 body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), 54 body('transcoding.resolutions.1440p').isBoolean(),
55 body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), 55 body('transcoding.resolutions.2160p').isBoolean(),
56 56
57 body('transcoding.alwaysTranscodeOriginalResolution').isBoolean() 57 body('transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
58 .withMessage('Should have a valid always transcode original resolution boolean'), 58
59 59 body('transcoding.webtorrent.enabled').isBoolean(),
60 body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), 60 body('transcoding.hls.enabled').isBoolean(),
61 body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'), 61
62 62 body('videoStudio.enabled').isBoolean(),
63 body('videoStudio.enabled').isBoolean().withMessage('Should have a valid video studio enabled boolean'), 63
64 64 body('import.videos.concurrency').isInt({ min: 0 }),
65 body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'), 65 body('import.videos.http.enabled').isBoolean(),
66 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), 66 body('import.videos.torrent.enabled').isBoolean(),
67 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), 67
68 68 body('import.videoChannelSynchronization.enabled').isBoolean(),
69 body('import.videoChannelSynchronization.enabled').isBoolean().withMessage('Should have a valid synchronization enabled boolean'), 69
70 70 body('trending.videos.algorithms.default').exists(),
71 body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'), 71 body('trending.videos.algorithms.enabled').exists(),
72 body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'), 72
73 73 body('followers.instance.enabled').isBoolean(),
74 body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), 74 body('followers.instance.manualApproval').isBoolean(),
75 body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), 75
76 76 body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)),
77 body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), 77
78 78 body('broadcastMessage.enabled').isBoolean(),
79 body('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'), 79 body('broadcastMessage.message').exists(),
80 body('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'), 80 body('broadcastMessage.level').exists(),
81 body('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'), 81 body('broadcastMessage.dismissable').isBoolean(),
82 body('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'), 82
83 83 body('live.enabled').isBoolean(),
84 body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'), 84 body('live.allowReplay').isBoolean(),
85 body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'), 85 body('live.maxDuration').isInt(),
86 body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'), 86 body('live.maxInstanceLives').custom(isIntOrNull),
87 body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'), 87 body('live.maxUserLives').custom(isIntOrNull),
88 body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'), 88 body('live.transcoding.enabled').isBoolean(),
89 body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'), 89 body('live.transcoding.threads').isInt(),
90 body('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'), 90 body('live.transcoding.resolutions.144p').isBoolean(),
91 body('live.transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'), 91 body('live.transcoding.resolutions.240p').isBoolean(),
92 body('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), 92 body('live.transcoding.resolutions.360p').isBoolean(),
93 body('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), 93 body('live.transcoding.resolutions.480p').isBoolean(),
94 body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), 94 body('live.transcoding.resolutions.720p').isBoolean(),
95 body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), 95 body('live.transcoding.resolutions.1080p').isBoolean(),
96 body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), 96 body('live.transcoding.resolutions.1440p').isBoolean(),
97 body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), 97 body('live.transcoding.resolutions.2160p').isBoolean(),
98 body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), 98 body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
99 body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean() 99
100 .withMessage('Should have a valid always transcode live original resolution boolean'), 100 body('search.remoteUri.users').isBoolean(),
101 101 body('search.remoteUri.anonymous').isBoolean(),
102 body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'), 102 body('search.searchIndex.enabled').isBoolean(),
103 body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'), 103 body('search.searchIndex.url').exists(),
104 body('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'), 104 body('search.searchIndex.disableLocalSearch').isBoolean(),
105 body('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'), 105 body('search.searchIndex.isDefaultSearch').isBoolean(),
106 body('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'),
107 body('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'),
108 106
109 (req: express.Request, res: express.Response, next: express.NextFunction) => { 107 (req: express.Request, res: express.Response, next: express.NextFunction) => {
110 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) 108 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index 04b4e00c9..900c1d383 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -16,8 +16,20 @@ import {
16} from './shared' 16} from './shared'
17 17
18const feedsFormatValidator = [ 18const feedsFormatValidator = [
19 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 19 param('format')
20 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)') 20 .optional()
21 .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
22 query('format')
23 .optional()
24 .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
25
26 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking feeds format parameters', { parameters: req.query })
28
29 if (areValidationErrors(req, res)) return
30
31 return next()
32 }
21] 33]
22 34
23function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) { 35function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) {
@@ -49,16 +61,14 @@ function setFeedFormatContentType (req: express.Request, res: express.Response,
49const videoFeedsValidator = [ 61const videoFeedsValidator = [
50 query('accountId') 62 query('accountId')
51 .optional() 63 .optional()
52 .custom(isIdValid) 64 .custom(isIdValid),
53 .withMessage('Should have a valid account id'),
54 65
55 query('accountName') 66 query('accountName')
56 .optional(), 67 .optional(),
57 68
58 query('videoChannelId') 69 query('videoChannelId')
59 .optional() 70 .optional()
60 .custom(isIdValid) 71 .custom(isIdValid),
61 .withMessage('Should have a valid channel id'),
62 72
63 query('videoChannelName') 73 query('videoChannelName')
64 .optional(), 74 .optional(),
@@ -79,12 +89,10 @@ const videoFeedsValidator = [
79 89
80const videoSubscriptionFeedsValidator = [ 90const videoSubscriptionFeedsValidator = [
81 query('accountId') 91 query('accountId')
82 .custom(isIdValid) 92 .custom(isIdValid),
83 .withMessage('Should have a valid account id'),
84 93
85 query('token') 94 query('token')
86 .custom(exists) 95 .custom(exists),
87 .withMessage('Should have a token'),
88 96
89 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 97 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
90 logger.debug('Checking subscription feeds parameters', { parameters: req.query }) 98 logger.debug('Checking subscription feeds parameters', { parameters: req.query })
@@ -100,8 +108,8 @@ const videoSubscriptionFeedsValidator = [
100 108
101const videoCommentsFeedsValidator = [ 109const videoCommentsFeedsValidator = [
102 query('videoId') 110 query('videoId')
103 .customSanitizer(toCompleteUUID)
104 .optional() 111 .optional()
112 .customSanitizer(toCompleteUUID)
105 .custom(isIdOrUUIDValid), 113 .custom(isIdOrUUIDValid),
106 114
107 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 115 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 023dba5b5..639c60c03 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -19,10 +19,10 @@ import { areValidationErrors } from './shared'
19const listFollowsValidator = [ 19const listFollowsValidator = [
20 query('state') 20 query('state')
21 .optional() 21 .optional()
22 .custom(isFollowStateValid).withMessage('Should have a valid follow state'), 22 .custom(isFollowStateValid),
23 query('actorType') 23 query('actorType')
24 .optional() 24 .optional()
25 .custom(isActorTypeValid).withMessage('Should have a valid actor type'), 25 .custom(isActorTypeValid),
26 26
27 (req: express.Request, res: express.Response, next: express.NextFunction) => { 27 (req: express.Request, res: express.Response, next: express.NextFunction) => {
28 if (areValidationErrors(req, res)) return 28 if (areValidationErrors(req, res)) return
@@ -70,8 +70,7 @@ const followValidator = [
70 70
71const removeFollowingValidator = [ 71const removeFollowingValidator = [
72 param('hostOrHandle') 72 param('hostOrHandle')
73 .custom(value => isHostValid(value) || isRemoteHandleValid(value)) 73 .custom(value => isHostValid(value) || isRemoteHandleValid(value)),
74 .withMessage('Should have a valid host/handle'),
75 74
76 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 75 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
77 logger.debug('Checking unfollowing parameters', { parameters: req.params }) 76 logger.debug('Checking unfollowing parameters', { parameters: req.params })
@@ -100,7 +99,8 @@ const removeFollowingValidator = [
100] 99]
101 100
102const getFollowerValidator = [ 101const getFollowerValidator = [
103 param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'), 102 param('nameWithHost')
103 .custom(isValidActorHandle),
104 104
105 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 105 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
106 logger.debug('Checking get follower parameters', { parameters: req.params }) 106 logger.debug('Checking get follower parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts
index 4de90548b..971c2060c 100644
--- a/server/middlewares/validators/jobs.ts
+++ b/server/middlewares/validators/jobs.ts
@@ -8,12 +8,12 @@ const lTags = loggerTagsFactory('validators', 'jobs')
8 8
9const listJobsValidator = [ 9const listJobsValidator = [
10 param('state') 10 param('state')
11 .optional() 11 .optional()
12 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), 12 .custom(isValidJobState),
13 13
14 query('jobType') 14 query('jobType')
15 .optional() 15 .optional()
16 .custom(isValidJobType).withMessage('Should have a valid job state'), 16 .custom(isValidJobType),
17 17
18 (req: express.Request, res: express.Response, next: express.NextFunction) => { 18 (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() }) 19 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() })
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts
index 324ba6915..ce36dc40b 100644
--- a/server/middlewares/validators/logs.ts
+++ b/server/middlewares/validators/logs.ts
@@ -18,25 +18,25 @@ import { areValidationErrors } from './shared'
18 18
19const createClientLogValidator = [ 19const createClientLogValidator = [
20 body('message') 20 body('message')
21 .custom(isValidClientLogMessage).withMessage('Should have a valid log message'), 21 .custom(isValidClientLogMessage),
22 22
23 body('url') 23 body('url')
24 .custom(isUrlValid).withMessage('Should have a valid log url'), 24 .custom(isUrlValid),
25 25
26 body('level') 26 body('level')
27 .custom(isValidClientLogLevel).withMessage('Should have a valid log message'), 27 .custom(isValidClientLogLevel),
28 28
29 body('stackTrace') 29 body('stackTrace')
30 .optional() 30 .optional()
31 .custom(isValidClientLogStackTrace).withMessage('Should have a valid log stack trace'), 31 .custom(isValidClientLogStackTrace),
32 32
33 body('meta') 33 body('meta')
34 .optional() 34 .optional()
35 .custom(isValidClientLogMeta).withMessage('Should have a valid log meta'), 35 .custom(isValidClientLogMeta),
36 36
37 body('userAgent') 37 body('userAgent')
38 .optional() 38 .optional()
39 .custom(isValidClientLogUserAgent).withMessage('Should have a valid log user agent'), 39 .custom(isValidClientLogUserAgent),
40 40
41 (req: express.Request, res: express.Response, next: express.NextFunction) => { 41 (req: express.Request, res: express.Response, next: express.NextFunction) => {
42 logger.debug('Checking createClientLogValidator parameters.', { parameters: req.query }) 42 logger.debug('Checking createClientLogValidator parameters.', { parameters: req.query })
@@ -56,7 +56,7 @@ const getLogsValidator = [
56 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'), 56 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
57 query('level') 57 query('level')
58 .optional() 58 .optional()
59 .custom(isValidLogLevel).withMessage('Should have a valid level'), 59 .custom(isValidLogLevel),
60 query('tagsOneOf') 60 query('tagsOneOf')
61 .optional() 61 .optional()
62 .customSanitizer(toArray) 62 .customSanitizer(toArray)
diff --git a/server/middlewares/validators/metrics.ts b/server/middlewares/validators/metrics.ts
index b1dbec603..cd6f872da 100644
--- a/server/middlewares/validators/metrics.ts
+++ b/server/middlewares/validators/metrics.ts
@@ -9,30 +9,29 @@ import { areValidationErrors, doesVideoExist } from './shared'
9 9
10const addPlaybackMetricValidator = [ 10const addPlaybackMetricValidator = [
11 body('resolution') 11 body('resolution')
12 .isInt({ min: 0 }).withMessage('Invalid resolution'), 12 .isInt({ min: 0 }),
13 body('fps') 13 body('fps')
14 .optional() 14 .optional()
15 .isInt({ min: 0 }).withMessage('Invalid fps'), 15 .isInt({ min: 0 }),
16 body('playerMode') 16 body('playerMode')
17 .custom(isValidPlayerMode).withMessage('Invalid playerMode'), 17 .custom(isValidPlayerMode),
18 18
19 body('resolutionChanges') 19 body('resolutionChanges')
20 .isInt({ min: 0 }).withMessage('Invalid resolutionChanges'), 20 .isInt({ min: 0 }),
21 21
22 body('errors') 22 body('errors')
23 .isInt({ min: 0 }).withMessage('Invalid errors'), 23 .isInt({ min: 0 }),
24 24
25 body('downloadedBytesP2P') 25 body('downloadedBytesP2P')
26 .isInt({ min: 0 }).withMessage('Invalid downloadedBytesP2P'), 26 .isInt({ min: 0 }),
27 body('downloadedBytesHTTP') 27 body('downloadedBytesHTTP')
28 .isInt({ min: 0 }).withMessage('Invalid downloadedBytesHTTP'), 28 .isInt({ min: 0 }),
29 29
30 body('uploadedBytesP2P') 30 body('uploadedBytesP2P')
31 .isInt({ min: 0 }).withMessage('Invalid uploadedBytesP2P'), 31 .isInt({ min: 0 }),
32 32
33 body('videoId') 33 body('videoId')
34 .customSanitizer(toCompleteUUID) 34 .customSanitizer(toCompleteUUID)
35 .optional()
36 .custom(isIdOrUUIDValid), 35 .custom(isIdOrUUIDValid),
37 36
38 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 37 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index 8e7b44a86..fa90dd05c 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -39,10 +39,17 @@ if (isTestOrDevInstance()) {
39} 39}
40 40
41const oembedValidator = [ 41const oembedValidator = [
42 query('url').isURL(isURLOptions).withMessage('Should have a valid url'), 42 query('url')
43 query('maxwidth').optional().isInt().withMessage('Should have a valid max width'), 43 .isURL(isURLOptions),
44 query('maxheight').optional().isInt().withMessage('Should have a valid max height'), 44 query('maxwidth')
45 query('format').optional().isIn([ 'xml', 'json' ]).withMessage('Should have a valid format'), 45 .optional()
46 .isInt(),
47 query('maxheight')
48 .optional()
49 .isInt(),
50 query('format')
51 .optional()
52 .isIn([ 'xml', 'json' ]),
46 53
47 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 54 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking oembed parameters', { parameters: req.query }) 55 logger.debug('Checking oembed parameters', { parameters: req.query })
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts
index 8e4922b9d..ce371d6c1 100644
--- a/server/middlewares/validators/pagination.ts
+++ b/server/middlewares/validators/pagination.ts
@@ -10,7 +10,7 @@ function paginationValidatorBuilder (tags: string[] = []) {
10 return [ 10 return [
11 query('start') 11 query('start')
12 .optional() 12 .optional()
13 .isInt({ min: 0 }).withMessage('Should have a number start'), 13 .isInt({ min: 0 }),
14 query('count') 14 query('count')
15 .optional() 15 .optional()
16 .isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`), 16 .isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`),
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index c1e9ebefb..dc80469c3 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -13,12 +13,14 @@ import { areValidationErrors } from './shared'
13 13
14const getPluginValidator = (pluginType: PluginType, withVersion = true) => { 14const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
15 const validators: (ValidationChain | express.Handler)[] = [ 15 const validators: (ValidationChain | express.Handler)[] = [
16 param('pluginName').custom(isPluginNameValid).withMessage('Should have a valid plugin name') 16 param('pluginName')
17 .custom(isPluginNameValid)
17 ] 18 ]
18 19
19 if (withVersion) { 20 if (withVersion) {
20 validators.push( 21 validators.push(
21 param('pluginVersion').custom(isPluginVersionValid).withMessage('Should have a valid plugin version') 22 param('pluginVersion')
23 .custom(isPluginVersionValid)
22 ) 24 )
23 } 25 }
24 26
@@ -52,7 +54,8 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
52} 54}
53 55
54const getExternalAuthValidator = [ 56const getExternalAuthValidator = [
55 param('authName').custom(exists).withMessage('Should have a valid auth name'), 57 param('authName')
58 .custom(exists),
56 59
57 (req: express.Request, res: express.Response, next: express.NextFunction) => { 60 (req: express.Request, res: express.Response, next: express.NextFunction) => {
58 logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params }) 61 logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params })
@@ -82,7 +85,8 @@ const getExternalAuthValidator = [
82] 85]
83 86
84const pluginStaticDirectoryValidator = [ 87const pluginStaticDirectoryValidator = [
85 param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'), 88 param('staticEndpoint')
89 .custom(isSafePath),
86 90
87 (req: express.Request, res: express.Response, next: express.NextFunction) => { 91 (req: express.Request, res: express.Response, next: express.NextFunction) => {
88 logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params }) 92 logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params })
@@ -97,11 +101,11 @@ const listPluginsValidator = [
97 query('pluginType') 101 query('pluginType')
98 .optional() 102 .optional()
99 .customSanitizer(toIntOrNull) 103 .customSanitizer(toIntOrNull)
100 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 104 .custom(isPluginTypeValid),
101 query('uninstalled') 105 query('uninstalled')
102 .optional() 106 .optional()
103 .customSanitizer(toBooleanOrNull) 107 .customSanitizer(toBooleanOrNull)
104 .custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'), 108 .custom(isBooleanValid),
105 109
106 (req: express.Request, res: express.Response, next: express.NextFunction) => { 110 (req: express.Request, res: express.Response, next: express.NextFunction) => {
107 logger.debug('Checking listPluginsValidator parameters', { parameters: req.query }) 111 logger.debug('Checking listPluginsValidator parameters', { parameters: req.query })
@@ -115,13 +119,13 @@ const listPluginsValidator = [
115const installOrUpdatePluginValidator = [ 119const installOrUpdatePluginValidator = [
116 body('npmName') 120 body('npmName')
117 .optional() 121 .optional()
118 .custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'), 122 .custom(isNpmPluginNameValid),
119 body('pluginVersion') 123 body('pluginVersion')
120 .optional() 124 .optional()
121 .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'), 125 .custom(isPluginVersionValid),
122 body('path') 126 body('path')
123 .optional() 127 .optional()
124 .custom(isSafePath).withMessage('Should have a valid safe path'), 128 .custom(isSafePath),
125 129
126 (req: express.Request, res: express.Response, next: express.NextFunction) => { 130 (req: express.Request, res: express.Response, next: express.NextFunction) => {
127 logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body }) 131 logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body })
@@ -141,7 +145,8 @@ const installOrUpdatePluginValidator = [
141] 145]
142 146
143const uninstallPluginValidator = [ 147const uninstallPluginValidator = [
144 body('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'), 148 body('npmName')
149 .custom(isNpmPluginNameValid),
145 150
146 (req: express.Request, res: express.Response, next: express.NextFunction) => { 151 (req: express.Request, res: express.Response, next: express.NextFunction) => {
147 logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body }) 152 logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body })
@@ -153,7 +158,8 @@ const uninstallPluginValidator = [
153] 158]
154 159
155const existingPluginValidator = [ 160const existingPluginValidator = [
156 param('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid plugin name'), 161 param('npmName')
162 .custom(isNpmPluginNameValid),
157 163
158 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 164 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
159 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params }) 165 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params })
@@ -174,7 +180,8 @@ const existingPluginValidator = [
174] 180]
175 181
176const updatePluginSettingsValidator = [ 182const updatePluginSettingsValidator = [
177 body('settings').exists().withMessage('Should have settings'), 183 body('settings')
184 .exists(),
178 185
179 (req: express.Request, res: express.Response, next: express.NextFunction) => { 186 (req: express.Request, res: express.Response, next: express.NextFunction) => {
180 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body }) 187 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body })
@@ -188,14 +195,14 @@ const updatePluginSettingsValidator = [
188const listAvailablePluginsValidator = [ 195const listAvailablePluginsValidator = [
189 query('search') 196 query('search')
190 .optional() 197 .optional()
191 .exists().withMessage('Should have a valid search'), 198 .exists(),
192 query('pluginType') 199 query('pluginType')
193 .optional() 200 .optional()
194 .customSanitizer(toIntOrNull) 201 .customSanitizer(toIntOrNull)
195 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 202 .custom(isPluginTypeValid),
196 query('currentPeerTubeEngine') 203 query('currentPeerTubeEngine')
197 .optional() 204 .optional()
198 .custom(isPluginVersionValid).withMessage('Should have a valid current peertube engine'), 205 .custom(isPluginVersionValid),
199 206
200 (req: express.Request, res: express.Response, next: express.NextFunction) => { 207 (req: express.Request, res: express.Response, next: express.NextFunction) => {
201 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query }) 208 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index d31b216f5..a74772bd1 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -22,11 +22,11 @@ const videoFileRedundancyGetValidator = [
22 22
23 param('resolution') 23 param('resolution')
24 .customSanitizer(toIntOrNull) 24 .customSanitizer(toIntOrNull)
25 .custom(exists).withMessage('Should have a valid resolution'), 25 .custom(exists),
26 param('fps') 26 param('fps')
27 .optional() 27 .optional()
28 .customSanitizer(toIntOrNull) 28 .customSanitizer(toIntOrNull)
29 .custom(exists).withMessage('Should have a valid fps'), 29 .custom(exists),
30 30
31 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 31 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
32 logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params }) 32 logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })
@@ -69,7 +69,7 @@ const videoPlaylistRedundancyGetValidator = [
69 69
70 param('streamingPlaylistType') 70 param('streamingPlaylistType')
71 .customSanitizer(toIntOrNull) 71 .customSanitizer(toIntOrNull)
72 .custom(exists).withMessage('Should have a valid streaming playlist type'), 72 .custom(exists),
73 73
74 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 74 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
75 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params }) 75 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
@@ -104,10 +104,12 @@ const videoPlaylistRedundancyGetValidator = [
104] 104]
105 105
106const updateServerRedundancyValidator = [ 106const updateServerRedundancyValidator = [
107 param('host').custom(isHostValid).withMessage('Should have a valid host'), 107 param('host')
108 .custom(isHostValid),
109
108 body('redundancyAllowed') 110 body('redundancyAllowed')
109 .customSanitizer(toBooleanOrNull) 111 .customSanitizer(toBooleanOrNull)
110 .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'), 112 .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed boolean'),
111 113
112 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 114 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
113 logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params }) 115 logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params })
@@ -130,7 +132,7 @@ const updateServerRedundancyValidator = [
130 132
131const listVideoRedundanciesValidator = [ 133const listVideoRedundanciesValidator = [
132 query('target') 134 query('target')
133 .custom(isVideoRedundancyTarget).withMessage('Should have a valid video redundancies target'), 135 .custom(isVideoRedundancyTarget),
134 136
135 (req: express.Request, res: express.Response, next: express.NextFunction) => { 137 (req: express.Request, res: express.Response, next: express.NextFunction) => {
136 logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query }) 138 logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query })
@@ -144,8 +146,7 @@ const listVideoRedundanciesValidator = [
144const addVideoRedundancyValidator = [ 146const addVideoRedundancyValidator = [
145 body('videoId') 147 body('videoId')
146 .customSanitizer(toCompleteUUID) 148 .customSanitizer(toCompleteUUID)
147 .custom(isIdOrUUIDValid) 149 .custom(isIdOrUUIDValid),
148 .withMessage('Should have a valid video id'),
149 150
150 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 151 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
151 logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query }) 152 logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query })
@@ -176,8 +177,7 @@ const addVideoRedundancyValidator = [
176 177
177const removeVideoRedundancyValidator = [ 178const removeVideoRedundancyValidator = [
178 param('redundancyId') 179 param('redundancyId')
179 .custom(isIdValid) 180 .custom(isIdValid),
180 .withMessage('Should have a valid redundancy id'),
181 181
182 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 182 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
183 logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query }) 183 logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query })
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
index e6ec8642a..827132468 100644
--- a/server/middlewares/validators/search.ts
+++ b/server/middlewares/validators/search.ts
@@ -7,11 +7,13 @@ import { logger } from '../../helpers/logger'
7import { areValidationErrors } from './shared' 7import { areValidationErrors } from './shared'
8 8
9const videosSearchValidator = [ 9const videosSearchValidator = [
10 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 10 query('search')
11 .optional()
12 .not().isEmpty(),
11 13
12 query('host') 14 query('host')
13 .optional() 15 .optional()
14 .custom(isHostValid).withMessage('Should have a valid host'), 16 .custom(isHostValid),
15 17
16 query('startDate') 18 query('startDate')
17 .optional() 19 .optional()
@@ -29,18 +31,20 @@ const videosSearchValidator = [
29 31
30 query('durationMin') 32 query('durationMin')
31 .optional() 33 .optional()
32 .isInt().withMessage('Should have a valid min duration'), 34 .isInt(),
33 query('durationMax') 35 query('durationMax')
34 .optional() 36 .optional()
35 .isInt().withMessage('Should have a valid max duration'), 37 .isInt(),
36 38
37 query('uuids') 39 query('uuids')
38 .optional() 40 .optional()
39 .toArray() 41 .toArray()
40 .customSanitizer(toCompleteUUIDs) 42 .customSanitizer(toCompleteUUIDs)
41 .custom(areUUIDsValid).withMessage('Should have valid uuids'), 43 .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
42 44
43 query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'), 45 query('searchTarget')
46 .optional()
47 .custom(isSearchTargetValid),
44 48
45 (req: express.Request, res: express.Response, next: express.NextFunction) => { 49 (req: express.Request, res: express.Response, next: express.NextFunction) => {
46 logger.debug('Checking videos search query', { parameters: req.query }) 50 logger.debug('Checking videos search query', { parameters: req.query })
@@ -54,20 +58,20 @@ const videosSearchValidator = [
54const videoChannelsListSearchValidator = [ 58const videoChannelsListSearchValidator = [
55 query('search') 59 query('search')
56 .optional() 60 .optional()
57 .not().isEmpty().withMessage('Should have a valid search'), 61 .not().isEmpty(),
58 62
59 query('host') 63 query('host')
60 .optional() 64 .optional()
61 .custom(isHostValid).withMessage('Should have a valid host'), 65 .custom(isHostValid),
62 66
63 query('searchTarget') 67 query('searchTarget')
64 .optional() 68 .optional()
65 .custom(isSearchTargetValid).withMessage('Should have a valid search target'), 69 .custom(isSearchTargetValid),
66 70
67 query('handles') 71 query('handles')
68 .optional() 72 .optional()
69 .toArray() 73 .toArray()
70 .custom(isNotEmptyStringArray).withMessage('Should have valid handles'), 74 .custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'),
71 75
72 (req: express.Request, res: express.Response, next: express.NextFunction) => { 76 (req: express.Request, res: express.Response, next: express.NextFunction) => {
73 logger.debug('Checking video channels search query', { parameters: req.query }) 77 logger.debug('Checking video channels search query', { parameters: req.query })
@@ -81,21 +85,21 @@ const videoChannelsListSearchValidator = [
81const videoPlaylistsListSearchValidator = [ 85const videoPlaylistsListSearchValidator = [
82 query('search') 86 query('search')
83 .optional() 87 .optional()
84 .not().isEmpty().withMessage('Should have a valid search'), 88 .not().isEmpty(),
85 89
86 query('host') 90 query('host')
87 .optional() 91 .optional()
88 .custom(isHostValid).withMessage('Should have a valid host'), 92 .custom(isHostValid),
89 93
90 query('searchTarget') 94 query('searchTarget')
91 .optional() 95 .optional()
92 .custom(isSearchTargetValid).withMessage('Should have a valid search target'), 96 .custom(isSearchTargetValid),
93 97
94 query('uuids') 98 query('uuids')
95 .optional() 99 .optional()
96 .toArray() 100 .toArray()
97 .customSanitizer(toCompleteUUIDs) 101 .customSanitizer(toCompleteUUIDs)
98 .custom(areUUIDsValid).withMessage('Should have valid uuids'), 102 .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
99 103
100 (req: express.Request, res: express.Response, next: express.NextFunction) => { 104 (req: express.Request, res: express.Response, next: express.NextFunction) => {
101 logger.debug('Checking video playlists search query', { parameters: req.query }) 105 logger.debug('Checking video playlists search query', { parameters: req.query })
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index 10bbefe38..f6177f600 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -33,11 +33,11 @@ const serverGetValidator = [
33 33
34const contactAdministratorValidator = [ 34const contactAdministratorValidator = [
35 body('fromName') 35 body('fromName')
36 .custom(isUserDisplayNameValid).withMessage('Should have a valid name'), 36 .custom(isUserDisplayNameValid),
37 body('fromEmail') 37 body('fromEmail')
38 .isEmail().withMessage('Should have a valid email'), 38 .isEmail(),
39 body('body') 39 body('body')
40 .custom(isValidContactBody).withMessage('Should have a valid body'), 40 .custom(isValidContactBody),
41 41
42 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 42 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
43 logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body }) 43 logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/shared/utils.ts b/server/middlewares/validators/shared/utils.ts
index 410de4d80..77b64bc7a 100644
--- a/server/middlewares/validators/shared/utils.ts
+++ b/server/middlewares/validators/shared/utils.ts
@@ -26,13 +26,13 @@ function areValidationErrors (req: express.Request, res: express.Response) {
26function isValidVideoIdParam (paramName: string) { 26function isValidVideoIdParam (paramName: string) {
27 return param(paramName) 27 return param(paramName)
28 .customSanitizer(toCompleteUUID) 28 .customSanitizer(toCompleteUUID)
29 .custom(isIdOrUUIDValid).withMessage('Should have a valid video id') 29 .custom(isIdOrUUIDValid).withMessage('Should have a valid video id (id, short UUID or UUID)')
30} 30}
31 31
32function isValidPlaylistIdParam (paramName: string) { 32function isValidPlaylistIdParam (paramName: string) {
33 return param(paramName) 33 return param(paramName)
34 .customSanitizer(toCompleteUUID) 34 .customSanitizer(toCompleteUUID)
35 .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id') 35 .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id (id, short UUID or UUID)')
36} 36}
37 37
38// --------------------------------------------------------------------------- 38// ---------------------------------------------------------------------------
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts
index 0354e3fc6..269f1be53 100644
--- a/server/middlewares/validators/sort.ts
+++ b/server/middlewares/validators/sort.ts
@@ -10,7 +10,9 @@ function checkSortFactory (columns: string[], tags: string[] = []) {
10 10
11function checkSort (sortableColumns: string[], tags: string[] = []) { 11function checkSort (sortableColumns: string[], tags: string[] = []) {
12 return [ 12 return [
13 query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'), 13 query('sort')
14 .optional()
15 .isIn(sortableColumns),
14 16
15 (req: express.Request, res: express.Response, next: express.NextFunction) => { 17 (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking sort parameters', { parameters: req.query, tags }) 18 logger.debug('Checking sort parameters', { parameters: req.query, tags })
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index 7b9fee858..f6a8c2d92 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -8,9 +8,12 @@ import { PluginManager } from '../../lib/plugins/plugin-manager'
8import { areValidationErrors } from './shared' 8import { areValidationErrors } from './shared'
9 9
10const serveThemeCSSValidator = [ 10const serveThemeCSSValidator = [
11 param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'), 11 param('themeName')
12 param('themeVersion').custom(isPluginVersionValid).withMessage('Should have a valid theme version'), 12 .custom(isPluginNameValid),
13 param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'), 13 param('themeVersion')
14 .custom(isPluginVersionValid),
15 param('staticEndpoint')
16 .custom(isSafePath),
14 17
15 (req: express.Request, res: express.Response, next: express.NextFunction) => { 18 (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking serveThemeCSS parameters', { parameters: req.params }) 19 logger.debug('Checking serveThemeCSS parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index 541910be5..23a00888c 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -7,7 +7,7 @@ import { areValidationErrors } from './shared'
7const userHistoryListValidator = [ 7const userHistoryListValidator = [
8 query('search') 8 query('search')
9 .optional() 9 .optional()
10 .custom(exists).withMessage('Should have a valid search'), 10 .custom(exists),
11 11
12 (req: express.Request, res: express.Response, next: express.NextFunction) => { 12 (req: express.Request, res: express.Response, next: express.NextFunction) => {
13 logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query }) 13 logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
@@ -34,7 +34,7 @@ const userHistoryRemoveAllValidator = [
34 34
35const userHistoryRemoveElementValidator = [ 35const userHistoryRemoveElementValidator = [
36 param('videoId') 36 param('videoId')
37 .custom(isIdValid).withMessage('Should have a valid video id'), 37 .custom(isIdValid),
38 38
39 (req: express.Request, res: express.Response, next: express.NextFunction) => { 39 (req: express.Request, res: express.Response, next: express.NextFunction) => {
40 logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params }) 40 logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts
index 4a7577d32..f46303ab8 100644
--- a/server/middlewares/validators/user-notifications.ts
+++ b/server/middlewares/validators/user-notifications.ts
@@ -22,29 +22,29 @@ const listUserNotificationsValidator = [
22 22
23const updateNotificationSettingsValidator = [ 23const updateNotificationSettingsValidator = [
24 body('newVideoFromSubscription') 24 body('newVideoFromSubscription')
25 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'), 25 .custom(isUserNotificationSettingValid),
26 body('newCommentOnMyVideo') 26 body('newCommentOnMyVideo')
27 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new comment on my video notification setting'), 27 .custom(isUserNotificationSettingValid),
28 body('abuseAsModerator') 28 body('abuseAsModerator')
29 .custom(isUserNotificationSettingValid).withMessage('Should have a valid abuse as moderator notification setting'), 29 .custom(isUserNotificationSettingValid),
30 body('videoAutoBlacklistAsModerator') 30 body('videoAutoBlacklistAsModerator')
31 .custom(isUserNotificationSettingValid).withMessage('Should have a valid video auto blacklist notification setting'), 31 .custom(isUserNotificationSettingValid),
32 body('blacklistOnMyVideo') 32 body('blacklistOnMyVideo')
33 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new blacklist on my video notification setting'), 33 .custom(isUserNotificationSettingValid),
34 body('myVideoImportFinished') 34 body('myVideoImportFinished')
35 .custom(isUserNotificationSettingValid).withMessage('Should have a valid video import finished video notification setting'), 35 .custom(isUserNotificationSettingValid),
36 body('myVideoPublished') 36 body('myVideoPublished')
37 .custom(isUserNotificationSettingValid).withMessage('Should have a valid video published notification setting'), 37 .custom(isUserNotificationSettingValid),
38 body('commentMention') 38 body('commentMention')
39 .custom(isUserNotificationSettingValid).withMessage('Should have a valid comment mention notification setting'), 39 .custom(isUserNotificationSettingValid),
40 body('newFollow') 40 body('newFollow')
41 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new follow notification setting'), 41 .custom(isUserNotificationSettingValid),
42 body('newUserRegistration') 42 body('newUserRegistration')
43 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new user registration notification setting'), 43 .custom(isUserNotificationSettingValid),
44 body('newInstanceFollower') 44 body('newInstanceFollower')
45 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance follower notification setting'), 45 .custom(isUserNotificationSettingValid),
46 body('autoInstanceFollowing') 46 body('autoInstanceFollowing')
47 .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance following notification setting'), 47 .custom(isUserNotificationSettingValid),
48 48
49 (req: express.Request, res: express.Response, next: express.NextFunction) => { 49 (req: express.Request, res: express.Response, next: express.NextFunction) => {
50 logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body }) 50 logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body })
@@ -58,7 +58,7 @@ const updateNotificationSettingsValidator = [
58const markAsReadUserNotificationsValidator = [ 58const markAsReadUserNotificationsValidator = [
59 body('ids') 59 body('ids')
60 .optional() 60 .optional()
61 .custom(isNotEmptyIntArray).withMessage('Should have a valid notification ids to mark as read'), 61 .custom(isNotEmptyIntArray).withMessage('Should have a valid array of notification ids'),
62 62
63 (req: express.Request, res: express.Response, next: express.NextFunction) => { 63 (req: express.Request, res: express.Response, next: express.NextFunction) => {
64 logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body }) 64 logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index 73da3142a..d9e6aa667 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -9,7 +9,9 @@ import { ActorFollowModel } from '../../models/actor/actor-follow'
9import { areValidationErrors } from './shared' 9import { areValidationErrors } from './shared'
10 10
11const userSubscriptionListValidator = [ 11const userSubscriptionListValidator = [
12 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 12 query('search')
13 .optional()
14 .not().isEmpty(),
13 15
14 (req: express.Request, res: express.Response, next: express.NextFunction) => { 16 (req: express.Request, res: express.Response, next: express.NextFunction) => {
15 logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query }) 17 logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query })
@@ -21,7 +23,8 @@ const userSubscriptionListValidator = [
21] 23]
22 24
23const userSubscriptionAddValidator = [ 25const userSubscriptionAddValidator = [
24 body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), 26 body('uri')
27 .custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
25 28
26 (req: express.Request, res: express.Response, next: express.NextFunction) => { 29 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body }) 30 logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body })
@@ -35,7 +38,7 @@ const userSubscriptionAddValidator = [
35const areSubscriptionsExistValidator = [ 38const areSubscriptionsExistValidator = [
36 query('uris') 39 query('uris')
37 .customSanitizer(toArray) 40 .customSanitizer(toArray)
38 .custom(areValidActorHandles).withMessage('Should have a valid uri array'), 41 .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),
39 42
40 (req: express.Request, res: express.Response, next: express.NextFunction) => { 43 (req: express.Request, res: express.Response, next: express.NextFunction) => {
41 logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query }) 44 logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })
@@ -47,7 +50,8 @@ const areSubscriptionsExistValidator = [
47] 50]
48 51
49const userSubscriptionGetValidator = [ 52const userSubscriptionGetValidator = [
50 param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'), 53 param('uri')
54 .custom(isValidActorHandle),
51 55
52 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 56 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
53 logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params }) 57 logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 6d306121e..c3a07fccd 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -38,7 +38,7 @@ const usersListValidator = [
38 query('blocked') 38 query('blocked')
39 .optional() 39 .optional()
40 .customSanitizer(toBooleanOrNull) 40 .customSanitizer(toBooleanOrNull)
41 .isBoolean().withMessage('Should be a valid boolean banned state'), 41 .isBoolean().withMessage('Should be a valid blocked boolena'),
42 42
43 (req: express.Request, res: express.Response, next: express.NextFunction) => { 43 (req: express.Request, res: express.Response, next: express.NextFunction) => {
44 logger.debug('Checking usersList parameters', { parameters: req.query }) 44 logger.debug('Checking usersList parameters', { parameters: req.query })
@@ -50,19 +50,30 @@ const usersListValidator = [
50] 50]
51 51
52const usersAddValidator = [ 52const usersAddValidator = [
53 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), 53 body('username')
54 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), 54 .custom(isUserUsernameValid)
55 body('email').isEmail().withMessage('Should have a valid email'), 55 .withMessage('Should have a valid username (lowercase alphanumeric characters)'),
56 body('password')
57 .custom(isUserPasswordValidOrEmpty),
58 body('email')
59 .isEmail(),
56 60
57 body('channelName').optional().custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), 61 body('channelName')
62 .optional()
63 .custom(isVideoChannelUsernameValid),
58 64
59 body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), 65 body('videoQuota')
60 body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), 66 .custom(isUserVideoQuotaValid),
67 body('videoQuotaDaily')
68 .custom(isUserVideoQuotaDailyValid),
61 69
62 body('role') 70 body('role')
63 .customSanitizer(toIntOrNull) 71 .customSanitizer(toIntOrNull)
64 .custom(isUserRoleValid).withMessage('Should have a valid role'), 72 .custom(isUserRoleValid),
65 body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), 73
74 body('adminFlags')
75 .optional()
76 .custom(isUserAdminFlagsValid),
66 77
67 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 78 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
68 logger.debug('Checking usersAdd parameters', { parameters: omit(req.body, 'password') }) 79 logger.debug('Checking usersAdd parameters', { parameters: omit(req.body, 'password') })
@@ -97,19 +108,22 @@ const usersAddValidator = [
97] 108]
98 109
99const usersRegisterValidator = [ 110const usersRegisterValidator = [
100 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username'), 111 body('username')
101 body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'), 112 .custom(isUserUsernameValid),
102 body('email').isEmail().withMessage('Should have a valid email'), 113 body('password')
114 .custom(isUserPasswordValid),
115 body('email')
116 .isEmail(),
103 body('displayName') 117 body('displayName')
104 .optional() 118 .optional()
105 .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), 119 .custom(isUserDisplayNameValid),
106 120
107 body('channel.name') 121 body('channel.name')
108 .optional() 122 .optional()
109 .custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), 123 .custom(isVideoChannelUsernameValid),
110 body('channel.displayName') 124 body('channel.displayName')
111 .optional() 125 .optional()
112 .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), 126 .custom(isVideoChannelDisplayNameValid),
113 127
114 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 128 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
115 logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') }) 129 logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') })
@@ -141,7 +155,8 @@ const usersRegisterValidator = [
141] 155]
142 156
143const usersRemoveValidator = [ 157const usersRemoveValidator = [
144 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 158 param('id')
159 .custom(isIdValid),
145 160
146 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 161 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
147 logger.debug('Checking usersRemove parameters', { parameters: req.params }) 162 logger.debug('Checking usersRemove parameters', { parameters: req.params })
@@ -159,8 +174,11 @@ const usersRemoveValidator = [
159] 174]
160 175
161const usersBlockingValidator = [ 176const usersBlockingValidator = [
162 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 177 param('id')
163 body('reason').optional().custom(isUserBlockedReasonValid).withMessage('Should have a valid blocking reason'), 178 .custom(isIdValid),
179 body('reason')
180 .optional()
181 .custom(isUserBlockedReasonValid),
164 182
165 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 183 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
166 logger.debug('Checking usersBlocking parameters', { parameters: req.params }) 184 logger.debug('Checking usersBlocking parameters', { parameters: req.params })
@@ -189,19 +207,33 @@ const deleteMeValidator = [
189] 207]
190 208
191const usersUpdateValidator = [ 209const usersUpdateValidator = [
192 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 210 param('id').custom(isIdValid),
193 211
194 body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), 212 body('password')
195 body('email').optional().isEmail().withMessage('Should have a valid email attribute'), 213 .optional()
196 body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'), 214 .custom(isUserPasswordValid),
197 body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), 215 body('email')
198 body('videoQuotaDaily').optional().custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), 216 .optional()
199 body('pluginAuth').optional(), 217 .isEmail(),
218 body('emailVerified')
219 .optional()
220 .isBoolean(),
221 body('videoQuota')
222 .optional()
223 .custom(isUserVideoQuotaValid),
224 body('videoQuotaDaily')
225 .optional()
226 .custom(isUserVideoQuotaDailyValid),
227 body('pluginAuth')
228 .optional()
229 .exists(),
200 body('role') 230 body('role')
201 .optional() 231 .optional()
202 .customSanitizer(toIntOrNull) 232 .customSanitizer(toIntOrNull)
203 .custom(isUserRoleValid).withMessage('Should have a valid role'), 233 .custom(isUserRoleValid),
204 body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'), 234 body('adminFlags')
235 .optional()
236 .custom(isUserAdminFlagsValid),
205 237
206 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 238 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
207 logger.debug('Checking usersUpdate parameters', { parameters: req.body }) 239 logger.debug('Checking usersUpdate parameters', { parameters: req.body })
@@ -221,37 +253,37 @@ const usersUpdateValidator = [
221const usersUpdateMeValidator = [ 253const usersUpdateMeValidator = [
222 body('displayName') 254 body('displayName')
223 .optional() 255 .optional()
224 .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), 256 .custom(isUserDisplayNameValid),
225 body('description') 257 body('description')
226 .optional() 258 .optional()
227 .custom(isUserDescriptionValid).withMessage('Should have a valid description'), 259 .custom(isUserDescriptionValid),
228 body('currentPassword') 260 body('currentPassword')
229 .optional() 261 .optional()
230 .custom(isUserPasswordValid).withMessage('Should have a valid current password'), 262 .custom(isUserPasswordValid),
231 body('password') 263 body('password')
232 .optional() 264 .optional()
233 .custom(isUserPasswordValid).withMessage('Should have a valid password'), 265 .custom(isUserPasswordValid),
234 body('email') 266 body('email')
235 .optional() 267 .optional()
236 .isEmail().withMessage('Should have a valid email attribute'), 268 .isEmail(),
237 body('nsfwPolicy') 269 body('nsfwPolicy')
238 .optional() 270 .optional()
239 .custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'), 271 .custom(isUserNSFWPolicyValid),
240 body('autoPlayVideo') 272 body('autoPlayVideo')
241 .optional() 273 .optional()
242 .custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'), 274 .custom(isUserAutoPlayVideoValid),
243 body('p2pEnabled') 275 body('p2pEnabled')
244 .optional() 276 .optional()
245 .custom(isUserP2PEnabledValid).withMessage('Should have a valid p2p enabled boolean'), 277 .custom(isUserP2PEnabledValid).withMessage('Should have a valid p2p enabled boolean'),
246 body('videoLanguages') 278 body('videoLanguages')
247 .optional() 279 .optional()
248 .custom(isUserVideoLanguages).withMessage('Should have a valid video languages attribute'), 280 .custom(isUserVideoLanguages),
249 body('videosHistoryEnabled') 281 body('videosHistoryEnabled')
250 .optional() 282 .optional()
251 .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), 283 .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled boolean'),
252 body('theme') 284 body('theme')
253 .optional() 285 .optional()
254 .custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), 286 .custom(v => isThemeNameValid(v) && isThemeRegistered(v)),
255 287
256 body('noInstanceConfigWarningModal') 288 body('noInstanceConfigWarningModal')
257 .optional() 289 .optional()
@@ -296,8 +328,11 @@ const usersUpdateMeValidator = [
296] 328]
297 329
298const usersGetValidator = [ 330const usersGetValidator = [
299 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 331 param('id')
300 query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'), 332 .custom(isIdValid),
333 query('withStats')
334 .optional()
335 .isBoolean().withMessage('Should have a valid withStats boolean'),
301 336
302 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 337 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
303 logger.debug('Checking usersGet parameters', { parameters: req.params }) 338 logger.debug('Checking usersGet parameters', { parameters: req.params })
@@ -326,12 +361,12 @@ const usersVideosValidator = [
326 query('isLive') 361 query('isLive')
327 .optional() 362 .optional()
328 .customSanitizer(toBooleanOrNull) 363 .customSanitizer(toBooleanOrNull)
329 .custom(isBooleanValid).withMessage('Should have a valid live boolean'), 364 .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),
330 365
331 query('channelId') 366 query('channelId')
332 .optional() 367 .optional()
333 .customSanitizer(toIntOrNull) 368 .customSanitizer(toIntOrNull)
334 .custom(isIdValid).withMessage('Should have a valid channel id'), 369 .custom(isIdValid),
335 370
336 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 371 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
337 logger.debug('Checking usersVideosValidator parameters', { parameters: req.query }) 372 logger.debug('Checking usersVideosValidator parameters', { parameters: req.query })
@@ -384,7 +419,8 @@ const ensureUserRegistrationAllowedForIP = [
384] 419]
385 420
386const usersAskResetPasswordValidator = [ 421const usersAskResetPasswordValidator = [
387 body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'), 422 body('email')
423 .isEmail(),
388 424
389 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 425 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
390 logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body }) 426 logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body })
@@ -403,9 +439,12 @@ const usersAskResetPasswordValidator = [
403] 439]
404 440
405const usersResetPasswordValidator = [ 441const usersResetPasswordValidator = [
406 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 442 param('id')
407 body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'), 443 .custom(isIdValid),
408 body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'), 444 body('verificationString')
445 .not().isEmpty(),
446 body('password')
447 .custom(isUserPasswordValid),
409 448
410 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 449 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
411 logger.debug('Checking usersResetPassword parameters', { parameters: req.params }) 450 logger.debug('Checking usersResetPassword parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index de11e69f2..f065f101c 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -29,7 +29,7 @@ const videosBlacklistAddValidator = [
29 .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'), 29 .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
30 body('reason') 30 body('reason')
31 .optional() 31 .optional()
32 .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), 32 .custom(isVideoBlacklistReasonValid),
33 33
34 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 34 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
35 logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params }) 35 logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index dfb8fefc5..fd6dd151a 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -18,7 +18,7 @@ const addVideoCaptionValidator = [
18 isValidVideoIdParam('videoId'), 18 isValidVideoIdParam('videoId'),
19 19
20 param('captionLanguage') 20 param('captionLanguage')
21 .custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'), 21 .custom(isVideoCaptionLanguageValid).not().isEmpty(),
22 22
23 body('captionfile') 23 body('captionfile')
24 .custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile')) 24 .custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile'))
diff --git a/server/middlewares/validators/videos/video-channel-sync.ts b/server/middlewares/validators/videos/video-channel-sync.ts
index 081f09bba..18d8d74d2 100644
--- a/server/middlewares/validators/videos/video-channel-sync.ts
+++ b/server/middlewares/validators/videos/video-channel-sync.ts
@@ -20,8 +20,11 @@ export const ensureSyncIsEnabled = (req: express.Request, res: express.Response,
20} 20}
21 21
22export const videoChannelSyncValidator = [ 22export const videoChannelSyncValidator = [
23 body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'), 23 body('externalChannelUrl')
24 body('videoChannelId').isInt().withMessage('Should have a valid video channel id'), 24 .custom(isUrlValid),
25
26 body('videoChannelId')
27 .isInt(),
25 28
26 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 29 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking videoChannelSync parameters', { parameters: req.body }) 30 logger.debug('Checking videoChannelSync parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index d53c777fa..ad1415691 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -19,10 +19,16 @@ import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExist
19import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs' 19import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs'
20 20
21export const videoChannelsAddValidator = [ 21export const videoChannelsAddValidator = [
22 body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), 22 body('name')
23 body('displayName').custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), 23 .custom(isVideoChannelUsernameValid),
24 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 24 body('displayName')
25 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), 25 .custom(isVideoChannelDisplayNameValid),
26 body('description')
27 .optional()
28 .custom(isVideoChannelDescriptionValid),
29 body('support')
30 .optional()
31 .custom(isVideoChannelSupportValid),
26 32
27 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 33 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
28 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }) 34 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
@@ -49,16 +55,18 @@ export const videoChannelsAddValidator = [
49] 55]
50 56
51export const videoChannelsUpdateValidator = [ 57export const videoChannelsUpdateValidator = [
52 param('nameWithHost').exists().withMessage('Should have an video channel name with host'), 58 param('nameWithHost')
59 .exists(),
60
53 body('displayName') 61 body('displayName')
54 .optional() 62 .optional()
55 .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), 63 .custom(isVideoChannelDisplayNameValid),
56 body('description') 64 body('description')
57 .optional() 65 .optional()
58 .custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 66 .custom(isVideoChannelDescriptionValid),
59 body('support') 67 body('support')
60 .optional() 68 .optional()
61 .custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), 69 .custom(isVideoChannelSupportValid),
62 body('bulkVideosSupportUpdate') 70 body('bulkVideosSupportUpdate')
63 .optional() 71 .optional()
64 .custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'), 72 .custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'),
@@ -83,7 +91,8 @@ export const videoChannelsRemoveValidator = [
83] 91]
84 92
85export const videoChannelsNameWithHostValidator = [ 93export const videoChannelsNameWithHostValidator = [
86 param('nameWithHost').exists().withMessage('Should have an video channel name with host'), 94 param('nameWithHost')
95 .exists(),
87 96
88 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 97 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
89 logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params }) 98 logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params })
@@ -124,7 +133,7 @@ export const videoChannelStatsValidator = [
124 query('withStats') 133 query('withStats')
125 .optional() 134 .optional()
126 .customSanitizer(toBooleanOrNull) 135 .customSanitizer(toBooleanOrNull)
127 .custom(isBooleanValid).withMessage('Should have a valid stats flag'), 136 .custom(isBooleanValid).withMessage('Should have a valid stats flag boolean'),
128 137
129 (req: express.Request, res: express.Response, next: express.NextFunction) => { 138 (req: express.Request, res: express.Response, next: express.NextFunction) => {
130 if (areValidationErrors(req, res)) return 139 if (areValidationErrors(req, res)) return
@@ -133,7 +142,9 @@ export const videoChannelStatsValidator = [
133] 142]
134 143
135export const videoChannelsListValidator = [ 144export const videoChannelsListValidator = [
136 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 145 query('search')
146 .optional()
147 .not().isEmpty(),
137 148
138 (req: express.Request, res: express.Response, next: express.NextFunction) => { 149 (req: express.Request, res: express.Response, next: express.NextFunction) => {
139 logger.debug('Checking video channels search query', { parameters: req.query }) 150 logger.debug('Checking video channels search query', { parameters: req.query })
@@ -145,11 +156,12 @@ export const videoChannelsListValidator = [
145] 156]
146 157
147export const videoChannelImportVideosValidator = [ 158export const videoChannelImportVideosValidator = [
148 body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'), 159 body('externalChannelUrl')
160 .custom(isUrlValid),
149 161
150 body('videoChannelSyncId') 162 body('videoChannelSyncId')
151 .optional() 163 .optional()
152 .custom(isIdValid).withMessage('Should have a valid channel sync id'), 164 .custom(isIdValid),
153 165
154 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 166 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
155 logger.debug('Checking videoChannelImport parameters', { parameters: req.body }) 167 logger.debug('Checking videoChannelImport parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 68f41e50e..b2a39617b 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -19,28 +19,28 @@ import {
19 19
20const listVideoCommentsValidator = [ 20const listVideoCommentsValidator = [
21 query('isLocal') 21 query('isLocal')
22 .optional() 22 .optional()
23 .customSanitizer(toBooleanOrNull) 23 .customSanitizer(toBooleanOrNull)
24 .custom(isBooleanValid) 24 .custom(isBooleanValid)
25 .withMessage('Should have a valid is local boolean'), 25 .withMessage('Should have a valid isLocal boolean'),
26 26
27 query('onLocalVideo') 27 query('onLocalVideo')
28 .optional() 28 .optional()
29 .customSanitizer(toBooleanOrNull) 29 .customSanitizer(toBooleanOrNull)
30 .custom(isBooleanValid) 30 .custom(isBooleanValid)
31 .withMessage('Should have a valid is on local video boolean'), 31 .withMessage('Should have a valid onLocalVideo boolean'),
32 32
33 query('search') 33 query('search')
34 .optional() 34 .optional()
35 .custom(exists).withMessage('Should have a valid search'), 35 .custom(exists),
36 36
37 query('searchAccount') 37 query('searchAccount')
38 .optional() 38 .optional()
39 .custom(exists).withMessage('Should have a valid account search'), 39 .custom(exists),
40 40
41 query('searchVideo') 41 query('searchVideo')
42 .optional() 42 .optional()
43 .custom(exists).withMessage('Should have a valid video search'), 43 .custom(exists),
44 44
45 (req: express.Request, res: express.Response, next: express.NextFunction) => { 45 (req: express.Request, res: express.Response, next: express.NextFunction) => {
46 logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query }) 46 logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
@@ -70,7 +70,7 @@ const listVideoThreadCommentsValidator = [
70 isValidVideoIdParam('videoId'), 70 isValidVideoIdParam('videoId'),
71 71
72 param('threadId') 72 param('threadId')
73 .custom(isIdValid).not().isEmpty().withMessage('Should have a valid threadId'), 73 .custom(isIdValid),
74 74
75 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 75 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
76 logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params }) 76 logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })
@@ -89,7 +89,7 @@ const addVideoCommentThreadValidator = [
89 isValidVideoIdParam('videoId'), 89 isValidVideoIdParam('videoId'),
90 90
91 body('text') 91 body('text')
92 .custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'), 92 .custom(isValidVideoCommentText),
93 93
94 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 94 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
95 logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body }) 95 logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })
@@ -109,9 +109,9 @@ const addVideoCommentThreadValidator = [
109const addVideoCommentReplyValidator = [ 109const addVideoCommentReplyValidator = [
110 isValidVideoIdParam('videoId'), 110 isValidVideoIdParam('videoId'),
111 111
112 param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), 112 param('commentId').custom(isIdValid),
113 113
114 body('text').custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'), 114 body('text').custom(isValidVideoCommentText),
115 115
116 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 116 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
117 logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body }) 117 logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })
@@ -133,7 +133,7 @@ const videoCommentGetValidator = [
133 isValidVideoIdParam('videoId'), 133 isValidVideoIdParam('videoId'),
134 134
135 param('commentId') 135 param('commentId')
136 .custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), 136 .custom(isIdValid),
137 137
138 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 138 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
139 logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params }) 139 logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
@@ -149,7 +149,8 @@ const videoCommentGetValidator = [
149const removeVideoCommentValidator = [ 149const removeVideoCommentValidator = [
150 isValidVideoIdParam('videoId'), 150 isValidVideoIdParam('videoId'),
151 151
152 param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'), 152 param('commentId')
153 .custom(isIdValid),
153 154
154 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 155 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
155 logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params }) 156 logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-files.ts b/server/middlewares/validators/videos/video-files.ts
index b3db3f4f7..b44c997e3 100644
--- a/server/middlewares/validators/videos/video-files.ts
+++ b/server/middlewares/validators/videos/video-files.ts
@@ -41,7 +41,7 @@ const videoFilesDeleteWebTorrentFileValidator = [
41 isValidVideoIdParam('id'), 41 isValidVideoIdParam('id'),
42 42
43 param('videoFileId') 43 param('videoFileId')
44 .custom(isIdValid).withMessage('Should have a valid file id'), 44 .custom(isIdValid),
45 45
46 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 46 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
47 logger.debug('Checking videoFilesDeleteWebTorrentFile parameters', { parameters: req.params }) 47 logger.debug('Checking videoFilesDeleteWebTorrentFile parameters', { parameters: req.params })
@@ -109,7 +109,7 @@ const videoFilesDeleteHLSFileValidator = [
109 isValidVideoIdParam('id'), 109 isValidVideoIdParam('id'),
110 110
111 param('videoFileId') 111 param('videoFileId')
112 .custom(isIdValid).withMessage('Should have a valid file id'), 112 .custom(isIdValid),
113 113
114 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 114 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
115 logger.debug('Checking videoFilesDeleteHLSFile parameters', { parameters: req.params }) 115 logger.debug('Checking videoFilesDeleteHLSFile parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 3115acb21..0ab9e6e6f 100644
--- a/server/middlewares/validators/videos/video-imports.ts
+++ b/server/middlewares/validators/videos/video-imports.ts
@@ -19,13 +19,13 @@ import { getCommonVideoEditAttributes } from './videos'
19const videoImportAddValidator = getCommonVideoEditAttributes().concat([ 19const videoImportAddValidator = getCommonVideoEditAttributes().concat([
20 body('channelId') 20 body('channelId')
21 .customSanitizer(toIntOrNull) 21 .customSanitizer(toIntOrNull)
22 .custom(isIdValid).withMessage('Should have correct video channel id'), 22 .custom(isIdValid),
23 body('targetUrl') 23 body('targetUrl')
24 .optional() 24 .optional()
25 .custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'), 25 .custom(isVideoImportTargetUrlValid),
26 body('magnetUri') 26 body('magnetUri')
27 .optional() 27 .optional()
28 .custom(isVideoMagnetUriValid).withMessage('Should have a valid video magnet URI'), 28 .custom(isVideoMagnetUriValid),
29 body('torrentfile') 29 body('torrentfile')
30 .custom((value, { req }) => isVideoImportTorrentFile(req.files)) 30 .custom((value, { req }) => isVideoImportTorrentFile(req.files))
31 .withMessage( 31 .withMessage(
@@ -95,7 +95,7 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([
95const getMyVideoImportsValidator = [ 95const getMyVideoImportsValidator = [
96 query('videoChannelSyncId') 96 query('videoChannelSyncId')
97 .optional() 97 .optional()
98 .custom(isIdValid).withMessage('Should have correct videoChannelSync id'), 98 .custom(isIdValid),
99 99
100 (req: express.Request, res: express.Response, next: express.NextFunction) => { 100 (req: express.Request, res: express.Response, next: express.NextFunction) => {
101 logger.debug('Checking getMyVideoImportsValidator parameters', { parameters: req.params }) 101 logger.debug('Checking getMyVideoImportsValidator parameters', { parameters: req.params })
@@ -108,7 +108,7 @@ const getMyVideoImportsValidator = [
108 108
109const videoImportDeleteValidator = [ 109const videoImportDeleteValidator = [
110 param('id') 110 param('id')
111 .custom(isIdValid).withMessage('Should have correct import id'), 111 .custom(isIdValid),
112 112
113 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 113 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
114 logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.params }) 114 logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.params })
@@ -131,7 +131,7 @@ const videoImportDeleteValidator = [
131 131
132const videoImportCancelValidator = [ 132const videoImportCancelValidator = [
133 param('id') 133 param('id')
134 .custom(isIdValid).withMessage('Should have correct import id'), 134 .custom(isIdValid),
135 135
136 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 136 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
137 logger.debug('Checking videoImportCancelValidator parameters', { parameters: req.params }) 137 logger.debug('Checking videoImportCancelValidator parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index 777b57e9a..a330d70a1 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -56,7 +56,7 @@ const videoLiveGetValidator = [
56const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ 56const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
57 body('channelId') 57 body('channelId')
58 .customSanitizer(toIntOrNull) 58 .customSanitizer(toIntOrNull)
59 .custom(isIdValid).withMessage('Should have correct video channel id'), 59 .custom(isIdValid),
60 60
61 body('name') 61 body('name')
62 .custom(isVideoNameValid).withMessage( 62 .custom(isVideoNameValid).withMessage(
@@ -66,18 +66,17 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
66 body('saveReplay') 66 body('saveReplay')
67 .optional() 67 .optional()
68 .customSanitizer(toBooleanOrNull) 68 .customSanitizer(toBooleanOrNull)
69 .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'), 69 .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),
70 70
71 body('permanentLive') 71 body('permanentLive')
72 .optional() 72 .optional()
73 .customSanitizer(toBooleanOrNull) 73 .customSanitizer(toBooleanOrNull)
74 .custom(isBooleanValid).withMessage('Should have a valid permanentLive attribute'), 74 .custom(isBooleanValid).withMessage('Should have a valid permanentLive boolean'),
75 75
76 body('latencyMode') 76 body('latencyMode')
77 .optional() 77 .optional()
78 .customSanitizer(toIntOrNull) 78 .customSanitizer(toIntOrNull)
79 .custom(isLiveLatencyModeValid) 79 .custom(isLiveLatencyModeValid),
80 .withMessage('Should have a valid latency mode attribute'),
81 80
82 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 81 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
83 logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body }) 82 logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body })
@@ -156,13 +155,12 @@ const videoLiveUpdateValidator = [
156 body('saveReplay') 155 body('saveReplay')
157 .optional() 156 .optional()
158 .customSanitizer(toBooleanOrNull) 157 .customSanitizer(toBooleanOrNull)
159 .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'), 158 .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),
160 159
161 body('latencyMode') 160 body('latencyMode')
162 .optional() 161 .optional()
163 .customSanitizer(toIntOrNull) 162 .customSanitizer(toIntOrNull)
164 .custom(isLiveLatencyModeValid) 163 .custom(isLiveLatencyModeValid),
165 .withMessage('Should have a valid latency mode attribute'),
166 164
167 (req: express.Request, res: express.Response, next: express.NextFunction) => { 165 (req: express.Request, res: express.Response, next: express.NextFunction) => {
168 logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body }) 166 logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/middlewares/validators/videos/video-ownership-changes.ts
index 6dcdc05f5..e73196f5b 100644
--- a/server/middlewares/validators/videos/video-ownership-changes.ts
+++ b/server/middlewares/validators/videos/video-ownership-changes.ts
@@ -41,7 +41,7 @@ const videosChangeOwnershipValidator = [
41 41
42const videosTerminateChangeOwnershipValidator = [ 42const videosTerminateChangeOwnershipValidator = [
43 param('id') 43 param('id')
44 .custom(isIdValid).withMessage('Should have a valid id'), 44 .custom(isIdValid),
45 45
46 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 46 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
47 logger.debug('Checking changeOwnership parameters', { parameters: req.params }) 47 logger.debug('Checking changeOwnership parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index d514ae0ad..42e6646f9 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -45,7 +45,7 @@ import {
45 45
46const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ 46const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
47 body('displayName') 47 body('displayName')
48 .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), 48 .custom(isVideoPlaylistNameValid),
49 49
50 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 50 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
51 logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }) 51 logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body })
@@ -73,7 +73,7 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([
73 73
74 body('displayName') 74 body('displayName')
75 .optional() 75 .optional()
76 .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), 76 .custom(isVideoPlaylistNameValid),
77 77
78 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 78 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
79 logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }) 79 logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body })
@@ -184,7 +184,9 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
184} 184}
185 185
186const videoPlaylistsSearchValidator = [ 186const videoPlaylistsSearchValidator = [
187 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 187 query('search')
188 .optional()
189 .not().isEmpty(),
188 190
189 (req: express.Request, res: express.Response, next: express.NextFunction) => { 191 (req: express.Request, res: express.Response, next: express.NextFunction) => {
190 logger.debug('Checking videoPlaylists search query', { parameters: req.query }) 192 logger.debug('Checking videoPlaylists search query', { parameters: req.query })
@@ -200,13 +202,13 @@ const videoPlaylistsAddVideoValidator = [
200 202
201 body('videoId') 203 body('videoId')
202 .customSanitizer(toCompleteUUID) 204 .customSanitizer(toCompleteUUID)
203 .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'), 205 .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),
204 body('startTimestamp') 206 body('startTimestamp')
205 .optional() 207 .optional()
206 .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), 208 .custom(isVideoPlaylistTimestampValid),
207 body('stopTimestamp') 209 body('stopTimestamp')
208 .optional() 210 .optional()
209 .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), 211 .custom(isVideoPlaylistTimestampValid),
210 212
211 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 213 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
212 logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params }) 214 logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params })
@@ -230,13 +232,13 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
230 isValidPlaylistIdParam('playlistId'), 232 isValidPlaylistIdParam('playlistId'),
231 param('playlistElementId') 233 param('playlistElementId')
232 .customSanitizer(toCompleteUUID) 234 .customSanitizer(toCompleteUUID)
233 .custom(isIdValid).withMessage('Should have an element id/uuid'), 235 .custom(isIdValid).withMessage('Should have an element id/uuid/short uuid'),
234 body('startTimestamp') 236 body('startTimestamp')
235 .optional() 237 .optional()
236 .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), 238 .custom(isVideoPlaylistTimestampValid),
237 body('stopTimestamp') 239 body('stopTimestamp')
238 .optional() 240 .optional()
239 .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), 241 .custom(isVideoPlaylistTimestampValid),
240 242
241 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 243 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
242 logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params }) 244 logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params })
@@ -266,7 +268,7 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
266const videoPlaylistElementAPGetValidator = [ 268const videoPlaylistElementAPGetValidator = [
267 isValidPlaylistIdParam('playlistId'), 269 isValidPlaylistIdParam('playlistId'),
268 param('playlistElementId') 270 param('playlistElementId')
269 .custom(isIdValid).withMessage('Should have an playlist element id'), 271 .custom(isIdValid),
270 272
271 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 273 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
272 logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params }) 274 logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params })
@@ -300,13 +302,14 @@ const videoPlaylistElementAPGetValidator = [
300 302
301const videoPlaylistsReorderVideosValidator = [ 303const videoPlaylistsReorderVideosValidator = [
302 isValidPlaylistIdParam('playlistId'), 304 isValidPlaylistIdParam('playlistId'),
305
303 body('startPosition') 306 body('startPosition')
304 .isInt({ min: 1 }).withMessage('Should have a valid start position'), 307 .isInt({ min: 1 }),
305 body('insertAfterPosition') 308 body('insertAfterPosition')
306 .isInt({ min: 0 }).withMessage('Should have a valid insert after position'), 309 .isInt({ min: 0 }),
307 body('reorderLength') 310 body('reorderLength')
308 .optional() 311 .optional()
309 .isInt({ min: 1 }).withMessage('Should have a valid range length'), 312 .isInt({ min: 1 }),
310 313
311 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 314 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
312 logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params }) 315 logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params })
@@ -340,7 +343,7 @@ const videoPlaylistsReorderVideosValidator = [
340const commonVideoPlaylistFiltersValidator = [ 343const commonVideoPlaylistFiltersValidator = [
341 query('playlistType') 344 query('playlistType')
342 .optional() 345 .optional()
343 .custom(isVideoPlaylistTypeValid).withMessage('Should have a valid playlist type'), 346 .custom(isVideoPlaylistTypeValid),
344 347
345 (req: express.Request, res: express.Response, next: express.NextFunction) => { 348 (req: express.Request, res: express.Response, next: express.NextFunction) => {
346 logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params }) 349 logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params })
@@ -399,11 +402,11 @@ function getCommonPlaylistEditAttributes () {
399 body('description') 402 body('description')
400 .optional() 403 .optional()
401 .customSanitizer(toValueOrNull) 404 .customSanitizer(toValueOrNull)
402 .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), 405 .custom(isVideoPlaylistDescriptionValid),
403 body('privacy') 406 body('privacy')
404 .optional() 407 .optional()
405 .customSanitizer(toIntOrNull) 408 .customSanitizer(toIntOrNull)
406 .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), 409 .custom(isVideoPlaylistPrivacyValid),
407 body('videoChannelId') 410 body('videoChannelId')
408 .optional() 411 .optional()
409 .customSanitizer(toIntOrNull) 412 .customSanitizer(toIntOrNull)
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 8b8eeedb6..0c02baafb 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -13,7 +13,8 @@ import { areValidationErrors, checkCanSeeVideo, doesVideoExist, isValidVideoIdPa
13const videoUpdateRateValidator = [ 13const videoUpdateRateValidator = [
14 isValidVideoIdParam('id'), 14 isValidVideoIdParam('id'),
15 15
16 body('rating').custom(isVideoRatingTypeValid).withMessage('Should have a valid rate type'), 16 body('rating')
17 .custom(isVideoRatingTypeValid),
17 18
18 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 19 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking videoRate parameters', { parameters: req.body }) 20 logger.debug('Checking videoRate parameters', { parameters: req.body })
@@ -29,8 +30,10 @@ const videoUpdateRateValidator = [
29 30
30const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) { 31const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {
31 return [ 32 return [
32 param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), 33 param('name')
33 param('videoId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoId'), 34 .custom(isAccountNameValid),
35 param('videoId')
36 .custom(isIdValid),
34 37
35 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 38 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
36 logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params }) 39 logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
@@ -53,7 +56,9 @@ const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {
53} 56}
54 57
55const videoRatingValidator = [ 58const videoRatingValidator = [
56 query('rating').optional().custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'), 59 query('rating')
60 .optional()
61 .custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),
57 62
58 (req: express.Request, res: express.Response, next: express.NextFunction) => { 63 (req: express.Request, res: express.Response, next: express.NextFunction) => {
59 logger.debug('Checking rating parameter', { parameters: req.params }) 64 logger.debug('Checking rating parameter', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.ts
index 0f04032bb..40337dcf1 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -10,7 +10,7 @@ const videosShareValidator = [
10 isValidVideoIdParam('id'), 10 isValidVideoIdParam('id'),
11 11
12 param('actorId') 12 param('actorId')
13 .custom(isIdValid).not().isEmpty().withMessage('Should have a valid actor id'), 13 .custom(isIdValid),
14 14
15 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 15 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking videoShare parameters', { parameters: req.params }) 16 logger.debug('Checking videoShare parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/video-stats.ts b/server/middlewares/validators/videos/video-stats.ts
index f17fbcc09..ddbf2a564 100644
--- a/server/middlewares/validators/videos/video-stats.ts
+++ b/server/middlewares/validators/videos/video-stats.ts
@@ -12,13 +12,11 @@ const videoOverallStatsValidator = [
12 12
13 query('startDate') 13 query('startDate')
14 .optional() 14 .optional()
15 .custom(isDateValid) 15 .custom(isDateValid),
16 .withMessage('Should have a valid start date'),
17 16
18 query('endDate') 17 query('endDate')
19 .optional() 18 .optional()
20 .custom(isDateValid) 19 .custom(isDateValid),
21 .withMessage('Should have a valid end date'),
22 20
23 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 21 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
24 logger.debug('Checking videoOverallStatsValidator parameters', { parameters: req.body }) 22 logger.debug('Checking videoOverallStatsValidator parameters', { parameters: req.body })
@@ -54,18 +52,15 @@ const videoTimeserieStatsValidator = [
54 isValidVideoIdParam('videoId'), 52 isValidVideoIdParam('videoId'),
55 53
56 param('metric') 54 param('metric')
57 .custom(isValidStatTimeserieMetric) 55 .custom(isValidStatTimeserieMetric),
58 .withMessage('Should have a valid timeserie metric'),
59 56
60 query('startDate') 57 query('startDate')
61 .optional() 58 .optional()
62 .custom(isDateValid) 59 .custom(isDateValid),
63 .withMessage('Should have a valid start date'),
64 60
65 query('endDate') 61 query('endDate')
66 .optional() 62 .optional()
67 .custom(isDateValid) 63 .custom(isDateValid),
68 .withMessage('Should have a valid end date'),
69 64
70 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 65 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
71 logger.debug('Checking videoTimeserieStatsValidator parameters', { parameters: req.body }) 66 logger.debug('Checking videoTimeserieStatsValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/video-studio.ts b/server/middlewares/validators/videos/video-studio.ts
index af7fe2283..d07e150ae 100644
--- a/server/middlewares/validators/videos/video-studio.ts
+++ b/server/middlewares/validators/videos/video-studio.ts
@@ -16,9 +16,11 @@ import { logger } from '../../../helpers/logger'
16import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared' 16import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared'
17 17
18const videoStudioAddEditionValidator = [ 18const videoStudioAddEditionValidator = [
19 param('videoId').custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'), 19 param('videoId')
20 .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),
20 21
21 body('tasks').custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'), 22 body('tasks')
23 .custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),
22 24
23 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 25 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
24 logger.debug('Checking videoStudioAddEditionValidator parameters.', { parameters: req.params, body: req.body, files: req.files }) 26 logger.debug('Checking videoStudioAddEditionValidator parameters.', { parameters: req.params, body: req.body, files: req.files })
diff --git a/server/middlewares/validators/videos/video-transcoding.ts b/server/middlewares/validators/videos/video-transcoding.ts
index da6638f4d..36b9799e6 100644
--- a/server/middlewares/validators/videos/video-transcoding.ts
+++ b/server/middlewares/validators/videos/video-transcoding.ts
@@ -11,7 +11,7 @@ const createTranscodingValidator = [
11 isValidVideoIdParam('videoId'), 11 isValidVideoIdParam('videoId'),
12 12
13 body('transcodingType') 13 body('transcodingType')
14 .custom(isValidCreateTranscodingType).withMessage('Should have a valid transcoding type'), 14 .custom(isValidCreateTranscodingType),
15 15
16 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 16 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
17 logger.debug('Checking createTranscodingValidator parameters', { parameters: req.body }) 17 logger.debug('Checking createTranscodingValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/video-view.ts b/server/middlewares/validators/videos/video-view.ts
index 2edcd140f..4927c04ad 100644
--- a/server/middlewares/validators/videos/video-view.ts
+++ b/server/middlewares/validators/videos/video-view.ts
@@ -10,7 +10,7 @@ import { getCachedVideoDuration } from '@server/lib/video'
10 10
11const getVideoLocalViewerValidator = [ 11const getVideoLocalViewerValidator = [
12 param('localViewerId') 12 param('localViewerId')
13 .custom(isIdValid).withMessage('Should have a valid local viewer id'), 13 .custom(isIdValid),
14 14
15 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 15 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params }) 16 logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params })
@@ -37,7 +37,7 @@ const videoViewValidator = [
37 body('currentTime') 37 body('currentTime')
38 .optional() // TODO: remove optional in a few versions, introduced in 4.2 38 .optional() // TODO: remove optional in a few versions, introduced in 4.2
39 .customSanitizer(toIntOrNull) 39 .customSanitizer(toIntOrNull)
40 .custom(isIntOrNull).withMessage('Should have correct current time'), 40 .custom(isIntOrNull),
41 41
42 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 42 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
43 logger.debug('Checking videoView parameters', { parameters: req.body }) 43 logger.debug('Checking videoView parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index c6d31f8f0..5e8e25a9c 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -69,7 +69,7 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
69 ), 69 ),
70 body('channelId') 70 body('channelId')
71 .customSanitizer(toIntOrNull) 71 .customSanitizer(toIntOrNull)
72 .custom(isIdValid).withMessage('Should have correct video channel id'), 72 .custom(isIdValid),
73 73
74 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 74 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
75 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) 75 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
@@ -167,9 +167,7 @@ const videosAddResumableValidator = [
167 */ 167 */
168const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ 168const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
169 body('filename') 169 body('filename')
170 .isString() 170 .exists(),
171 .exists()
172 .withMessage('Should have a valid filename'),
173 body('name') 171 body('name')
174 .trim() 172 .trim()
175 .custom(isVideoNameValid).withMessage( 173 .custom(isVideoNameValid).withMessage(
@@ -177,7 +175,7 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
177 ), 175 ),
178 body('channelId') 176 body('channelId')
179 .customSanitizer(toIntOrNull) 177 .customSanitizer(toIntOrNull)
180 .custom(isIdValid).withMessage('Should have correct video channel id'), 178 .custom(isIdValid),
181 179
182 header('x-upload-content-length') 180 header('x-upload-content-length')
183 .isNumeric() 181 .isNumeric()
@@ -230,7 +228,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
230 body('channelId') 228 body('channelId')
231 .optional() 229 .optional()
232 .customSanitizer(toIntOrNull) 230 .customSanitizer(toIntOrNull)
233 .custom(isIdValid).withMessage('Should have correct video channel id'), 231 .custom(isIdValid),
234 232
235 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 233 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
236 logger.debug('Checking videosUpdate parameters', { parameters: req.body }) 234 logger.debug('Checking videosUpdate parameters', { parameters: req.body })
@@ -341,8 +339,7 @@ const videosRemoveValidator = [
341const videosOverviewValidator = [ 339const videosOverviewValidator = [
342 query('page') 340 query('page')
343 .optional() 341 .optional()
344 .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT }) 342 .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT }),
345 .withMessage('Should have a valid pagination'),
346 343
347 (req: express.Request, res: express.Response, next: express.NextFunction) => { 344 (req: express.Request, res: express.Response, next: express.NextFunction) => {
348 if (areValidationErrors(req, res)) return 345 if (areValidationErrors(req, res)) return
@@ -367,35 +364,35 @@ function getCommonVideoEditAttributes () {
367 body('category') 364 body('category')
368 .optional() 365 .optional()
369 .customSanitizer(toIntOrNull) 366 .customSanitizer(toIntOrNull)
370 .custom(isVideoCategoryValid).withMessage('Should have a valid category'), 367 .custom(isVideoCategoryValid),
371 body('licence') 368 body('licence')
372 .optional() 369 .optional()
373 .customSanitizer(toIntOrNull) 370 .customSanitizer(toIntOrNull)
374 .custom(isVideoLicenceValid).withMessage('Should have a valid licence'), 371 .custom(isVideoLicenceValid),
375 body('language') 372 body('language')
376 .optional() 373 .optional()
377 .customSanitizer(toValueOrNull) 374 .customSanitizer(toValueOrNull)
378 .custom(isVideoLanguageValid).withMessage('Should have a valid language'), 375 .custom(isVideoLanguageValid),
379 body('nsfw') 376 body('nsfw')
380 .optional() 377 .optional()
381 .customSanitizer(toBooleanOrNull) 378 .customSanitizer(toBooleanOrNull)
382 .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), 379 .custom(isBooleanValid).withMessage('Should have a valid nsfw boolean'),
383 body('waitTranscoding') 380 body('waitTranscoding')
384 .optional() 381 .optional()
385 .customSanitizer(toBooleanOrNull) 382 .customSanitizer(toBooleanOrNull)
386 .custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'), 383 .custom(isBooleanValid).withMessage('Should have a valid waitTranscoding boolean'),
387 body('privacy') 384 body('privacy')
388 .optional() 385 .optional()
389 .customSanitizer(toValueOrNull) 386 .customSanitizer(toValueOrNull)
390 .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 387 .custom(isVideoPrivacyValid),
391 body('description') 388 body('description')
392 .optional() 389 .optional()
393 .customSanitizer(toValueOrNull) 390 .customSanitizer(toValueOrNull)
394 .custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 391 .custom(isVideoDescriptionValid),
395 body('support') 392 body('support')
396 .optional() 393 .optional()
397 .customSanitizer(toValueOrNull) 394 .customSanitizer(toValueOrNull)
398 .custom(isVideoSupportValid).withMessage('Should have a valid support text'), 395 .custom(isVideoSupportValid),
399 body('tags') 396 body('tags')
400 .optional() 397 .optional()
401 .customSanitizer(toValueOrNull) 398 .customSanitizer(toValueOrNull)
@@ -407,15 +404,15 @@ function getCommonVideoEditAttributes () {
407 body('commentsEnabled') 404 body('commentsEnabled')
408 .optional() 405 .optional()
409 .customSanitizer(toBooleanOrNull) 406 .customSanitizer(toBooleanOrNull)
410 .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), 407 .custom(isBooleanValid).withMessage('Should have commentsEnabled boolean'),
411 body('downloadEnabled') 408 body('downloadEnabled')
412 .optional() 409 .optional()
413 .customSanitizer(toBooleanOrNull) 410 .customSanitizer(toBooleanOrNull)
414 .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), 411 .custom(isBooleanValid).withMessage('Should have downloadEnabled boolean'),
415 body('originallyPublishedAt') 412 body('originallyPublishedAt')
416 .optional() 413 .optional()
417 .customSanitizer(toValueOrNull) 414 .customSanitizer(toValueOrNull)
418 .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), 415 .custom(isVideoOriginallyPublishedAtValid),
419 body('scheduleUpdate') 416 body('scheduleUpdate')
420 .optional() 417 .optional()
421 .customSanitizer(toValueOrNull), 418 .customSanitizer(toValueOrNull),
@@ -425,7 +422,7 @@ function getCommonVideoEditAttributes () {
425 body('scheduleUpdate.privacy') 422 body('scheduleUpdate.privacy')
426 .optional() 423 .optional()
427 .customSanitizer(toIntOrNull) 424 .customSanitizer(toIntOrNull)
428 .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy') 425 .custom(isScheduleVideoUpdatePrivacyValid)
429 ] as (ValidationChain | ExpressPromiseHandler)[] 426 ] as (ValidationChain | ExpressPromiseHandler)[]
430} 427}
431 428
@@ -433,59 +430,59 @@ const commonVideosFiltersValidator = [
433 query('categoryOneOf') 430 query('categoryOneOf')
434 .optional() 431 .optional()
435 .customSanitizer(toArray) 432 .customSanitizer(toArray)
436 .custom(isNumberArray).withMessage('Should have a valid one of category array'), 433 .custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'),
437 query('licenceOneOf') 434 query('licenceOneOf')
438 .optional() 435 .optional()
439 .customSanitizer(toArray) 436 .customSanitizer(toArray)
440 .custom(isNumberArray).withMessage('Should have a valid one of licence array'), 437 .custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'),
441 query('languageOneOf') 438 query('languageOneOf')
442 .optional() 439 .optional()
443 .customSanitizer(toArray) 440 .customSanitizer(toArray)
444 .custom(isStringArray).withMessage('Should have a valid one of language array'), 441 .custom(isStringArray).withMessage('Should have a valid languageOneOf array'),
445 query('privacyOneOf') 442 query('privacyOneOf')
446 .optional() 443 .optional()
447 .customSanitizer(toArray) 444 .customSanitizer(toArray)
448 .custom(isNumberArray).withMessage('Should have a valid one of privacy array'), 445 .custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'),
449 query('tagsOneOf') 446 query('tagsOneOf')
450 .optional() 447 .optional()
451 .customSanitizer(toArray) 448 .customSanitizer(toArray)
452 .custom(isStringArray).withMessage('Should have a valid one of tags array'), 449 .custom(isStringArray).withMessage('Should have a valid tagsOneOf array'),
453 query('tagsAllOf') 450 query('tagsAllOf')
454 .optional() 451 .optional()
455 .customSanitizer(toArray) 452 .customSanitizer(toArray)
456 .custom(isStringArray).withMessage('Should have a valid all of tags array'), 453 .custom(isStringArray).withMessage('Should have a valid tagsAllOf array'),
457 query('nsfw') 454 query('nsfw')
458 .optional() 455 .optional()
459 .custom(isBooleanBothQueryValid).withMessage('Should have a valid NSFW attribute'), 456 .custom(isBooleanBothQueryValid),
460 query('isLive') 457 query('isLive')
461 .optional() 458 .optional()
462 .customSanitizer(toBooleanOrNull) 459 .customSanitizer(toBooleanOrNull)
463 .custom(isBooleanValid).withMessage('Should have a valid live boolean'), 460 .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),
464 query('filter') 461 query('filter')
465 .optional() 462 .optional()
466 .custom(isVideoFilterValid).withMessage('Should have a valid filter attribute'), 463 .custom(isVideoFilterValid),
467 query('include') 464 query('include')
468 .optional() 465 .optional()
469 .custom(isVideoIncludeValid).withMessage('Should have a valid include attribute'), 466 .custom(isVideoIncludeValid),
470 query('isLocal') 467 query('isLocal')
471 .optional() 468 .optional()
472 .customSanitizer(toBooleanOrNull) 469 .customSanitizer(toBooleanOrNull)
473 .custom(isBooleanValid).withMessage('Should have a valid local boolean'), 470 .custom(isBooleanValid).withMessage('Should have a valid isLocal boolean'),
474 query('hasHLSFiles') 471 query('hasHLSFiles')
475 .optional() 472 .optional()
476 .customSanitizer(toBooleanOrNull) 473 .customSanitizer(toBooleanOrNull)
477 .custom(isBooleanValid).withMessage('Should have a valid has hls boolean'), 474 .custom(isBooleanValid).withMessage('Should have a valid hasHLSFiles boolean'),
478 query('hasWebtorrentFiles') 475 query('hasWebtorrentFiles')
479 .optional() 476 .optional()
480 .customSanitizer(toBooleanOrNull) 477 .customSanitizer(toBooleanOrNull)
481 .custom(isBooleanValid).withMessage('Should have a valid has webtorrent boolean'), 478 .custom(isBooleanValid).withMessage('Should have a valid hasWebtorrentFiles boolean'),
482 query('skipCount') 479 query('skipCount')
483 .optional() 480 .optional()
484 .customSanitizer(toBooleanOrNull) 481 .customSanitizer(toBooleanOrNull)
485 .custom(isBooleanValid).withMessage('Should have a valid skip count boolean'), 482 .custom(isBooleanValid).withMessage('Should have a valid skipCount boolean'),
486 query('search') 483 query('search')
487 .optional() 484 .optional()
488 .custom(exists).withMessage('Should have a valid search'), 485 .custom(exists),
489 486
490 (req: express.Request, res: express.Response, next: express.NextFunction) => { 487 (req: express.Request, res: express.Response, next: express.NextFunction) => {
491 logger.debug('Checking commons video filters query', { parameters: req.query }) 488 logger.debug('Checking commons video filters query', { parameters: req.query })
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 8893a0c7e..4c176f162 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -8,7 +8,8 @@ import { ActorModel } from '../../models/actor/actor'
8import { areValidationErrors } from './shared' 8import { areValidationErrors } from './shared'
9 9
10const webfingerValidator = [ 10const webfingerValidator = [
11 query('resource').custom(isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'), 11 query('resource')
12 .custom(isWebfingerLocalResourceValid),
12 13
13 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 14 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
14 logger.debug('Checking webfinger parameters', { parameters: req.query }) 15 logger.debug('Checking webfinger parameters', { parameters: req.query })