aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/blocklist.ts6
-rw-r--r--server/middlewares/validators/logs.ts5
-rw-r--r--server/middlewares/validators/user-subscriptions.ts4
-rw-r--r--server/middlewares/validators/videos/videos.ts15
4 files changed, 15 insertions, 15 deletions
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 1bae3764a..8ec6cb01d 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,8 +1,8 @@
1import express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor' 3import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor'
4import { toArray } from '@server/helpers/custom-validators/misc'
5import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
5import { arrayify } from '@shared/core-utils'
6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
7import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' 7import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
8import { WEBSERVER } from '../../initializers/constants' 8import { WEBSERVER } from '../../initializers/constants'
@@ -121,12 +121,12 @@ const unblockServerByServerValidator = [
121const blocklistStatusValidator = [ 121const blocklistStatusValidator = [
122 query('hosts') 122 query('hosts')
123 .optional() 123 .optional()
124 .customSanitizer(toArray) 124 .customSanitizer(arrayify)
125 .custom(isEachUniqueHostValid).withMessage('Should have a valid hosts array'), 125 .custom(isEachUniqueHostValid).withMessage('Should have a valid hosts array'),
126 126
127 query('accounts') 127 query('accounts')
128 .optional() 128 .optional()
129 .customSanitizer(toArray) 129 .customSanitizer(arrayify)
130 .custom(areValidActorHandles).withMessage('Should have a valid accounts array'), 130 .custom(areValidActorHandles).withMessage('Should have a valid accounts array'),
131 131
132 (req: express.Request, res: express.Response, next: express.NextFunction) => { 132 (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts
index 584cb2aaf..2d828bb42 100644
--- a/server/middlewares/validators/logs.ts
+++ b/server/middlewares/validators/logs.ts
@@ -3,6 +3,7 @@ import { body, query } from 'express-validator'
3import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 3import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
4import { isStringArray } from '@server/helpers/custom-validators/search' 4import { isStringArray } from '@server/helpers/custom-validators/search'
5import { CONFIG } from '@server/initializers/config' 5import { CONFIG } from '@server/initializers/config'
6import { arrayify } from '@shared/core-utils'
6import { HttpStatusCode } from '@shared/models' 7import { HttpStatusCode } from '@shared/models'
7import { 8import {
8 isValidClientLogLevel, 9 isValidClientLogLevel,
@@ -12,7 +13,7 @@ import {
12 isValidClientLogUserAgent, 13 isValidClientLogUserAgent,
13 isValidLogLevel 14 isValidLogLevel
14} from '../../helpers/custom-validators/logs' 15} from '../../helpers/custom-validators/logs'
15import { isDateValid, toArray } from '../../helpers/custom-validators/misc' 16import { isDateValid } from '../../helpers/custom-validators/misc'
16import { areValidationErrors } from './shared' 17import { areValidationErrors } from './shared'
17 18
18const createClientLogValidator = [ 19const createClientLogValidator = [
@@ -56,7 +57,7 @@ const getLogsValidator = [
56 .custom(isValidLogLevel), 57 .custom(isValidLogLevel),
57 query('tagsOneOf') 58 query('tagsOneOf')
58 .optional() 59 .optional()
59 .customSanitizer(toArray) 60 .customSanitizer(arrayify)
60 .custom(isStringArray).withMessage('Should have a valid one of tags array'), 61 .custom(isStringArray).withMessage('Should have a valid one of tags array'),
61 query('endDate') 62 query('endDate')
62 .optional() 63 .optional()
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index a76628915..d01043c17 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,8 +1,8 @@
1import { arrayify } from '@shared/core-utils'
1import express from 'express' 2import express from 'express'
2import { body, param, query } from 'express-validator' 3import { body, param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 5import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
5import { toArray } from '../../helpers/custom-validators/misc'
6import { WEBSERVER } from '../../initializers/constants' 6import { WEBSERVER } from '../../initializers/constants'
7import { ActorFollowModel } from '../../models/actor/actor-follow' 7import { ActorFollowModel } from '../../models/actor/actor-follow'
8import { areValidationErrors } from './shared' 8import { areValidationErrors } from './shared'
@@ -32,7 +32,7 @@ const userSubscriptionAddValidator = [
32 32
33const areSubscriptionsExistValidator = [ 33const areSubscriptionsExistValidator = [
34 query('uris') 34 query('uris')
35 .customSanitizer(toArray) 35 .customSanitizer(arrayify)
36 .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'), 36 .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),
37 37
38 (req: express.Request, res: express.Response, next: express.NextFunction) => { 38 (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 3d93bc62f..7fd2b03d1 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -6,7 +6,7 @@ import { Redis } from '@server/lib/redis'
6import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
7import { ExpressPromiseHandler } from '@server/types/express-handler' 7import { ExpressPromiseHandler } from '@server/types/express-handler'
8import { MUserAccountId, MVideoFullLight } from '@server/types/models' 8import { MUserAccountId, MVideoFullLight } from '@server/types/models'
9import { getAllPrivacies } from '@shared/core-utils' 9import { arrayify, getAllPrivacies } from '@shared/core-utils'
10import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude } from '@shared/models' 10import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude } from '@shared/models'
11import { 11import {
12 exists, 12 exists,
@@ -14,7 +14,6 @@ import {
14 isDateValid, 14 isDateValid,
15 isFileValid, 15 isFileValid,
16 isIdValid, 16 isIdValid,
17 toArray,
18 toBooleanOrNull, 17 toBooleanOrNull,
19 toIntOrNull, 18 toIntOrNull,
20 toValueOrNull 19 toValueOrNull
@@ -419,27 +418,27 @@ function getCommonVideoEditAttributes () {
419const commonVideosFiltersValidator = [ 418const commonVideosFiltersValidator = [
420 query('categoryOneOf') 419 query('categoryOneOf')
421 .optional() 420 .optional()
422 .customSanitizer(toArray) 421 .customSanitizer(arrayify)
423 .custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'), 422 .custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'),
424 query('licenceOneOf') 423 query('licenceOneOf')
425 .optional() 424 .optional()
426 .customSanitizer(toArray) 425 .customSanitizer(arrayify)
427 .custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'), 426 .custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'),
428 query('languageOneOf') 427 query('languageOneOf')
429 .optional() 428 .optional()
430 .customSanitizer(toArray) 429 .customSanitizer(arrayify)
431 .custom(isStringArray).withMessage('Should have a valid languageOneOf array'), 430 .custom(isStringArray).withMessage('Should have a valid languageOneOf array'),
432 query('privacyOneOf') 431 query('privacyOneOf')
433 .optional() 432 .optional()
434 .customSanitizer(toArray) 433 .customSanitizer(arrayify)
435 .custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'), 434 .custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'),
436 query('tagsOneOf') 435 query('tagsOneOf')
437 .optional() 436 .optional()
438 .customSanitizer(toArray) 437 .customSanitizer(arrayify)
439 .custom(isStringArray).withMessage('Should have a valid tagsOneOf array'), 438 .custom(isStringArray).withMessage('Should have a valid tagsOneOf array'),
440 query('tagsAllOf') 439 query('tagsAllOf')
441 .optional() 440 .optional()
442 .customSanitizer(toArray) 441 .customSanitizer(arrayify)
443 .custom(isStringArray).withMessage('Should have a valid tagsAllOf array'), 442 .custom(isStringArray).withMessage('Should have a valid tagsAllOf array'),
444 query('nsfw') 443 query('nsfw')
445 .optional() 444 .optional()