diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-17 15:44:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-17 15:47:54 +0200 |
commit | 863477173efa82a4412d2e522aa46462249f9199 (patch) | |
tree | 40f0ae28691780d79acef5ba4dbd2ef0694ce8ff /server/middlewares/validators | |
parent | e0faa8ad6e18ce6248ef1ec93a59dab5b05be468 (diff) | |
download | PeerTube-863477173efa82a4412d2e522aa46462249f9199.tar.gz PeerTube-863477173efa82a4412d2e522aa46462249f9199.tar.zst PeerTube-863477173efa82a4412d2e522aa46462249f9199.zip |
Cleanup tests imports
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/blocklist.ts | 6 | ||||
-rw-r--r-- | server/middlewares/validators/logs.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/user-subscriptions.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 15 |
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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor' | 3 | import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor' |
4 | import { toArray } from '@server/helpers/custom-validators/misc' | ||
5 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | import { arrayify } from '@shared/core-utils' | ||
6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
7 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' | 7 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
8 | import { WEBSERVER } from '../../initializers/constants' | 8 | import { WEBSERVER } from '../../initializers/constants' |
@@ -121,12 +121,12 @@ const unblockServerByServerValidator = [ | |||
121 | const blocklistStatusValidator = [ | 121 | const 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' | |||
3 | import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { isStringArray } from '@server/helpers/custom-validators/search' | 4 | import { isStringArray } from '@server/helpers/custom-validators/search' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
6 | import { arrayify } from '@shared/core-utils' | ||
6 | import { HttpStatusCode } from '@shared/models' | 7 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 8 | import { |
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' |
15 | import { isDateValid, toArray } from '../../helpers/custom-validators/misc' | 16 | import { isDateValid } from '../../helpers/custom-validators/misc' |
16 | import { areValidationErrors } from './shared' | 17 | import { areValidationErrors } from './shared' |
17 | 18 | ||
18 | const createClientLogValidator = [ | 19 | const 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 @@ | |||
1 | import { arrayify } from '@shared/core-utils' | ||
1 | import express from 'express' | 2 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 3 | import { body, param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 5 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
5 | import { toArray } from '../../helpers/custom-validators/misc' | ||
6 | import { WEBSERVER } from '../../initializers/constants' | 6 | import { WEBSERVER } from '../../initializers/constants' |
7 | import { ActorFollowModel } from '../../models/actor/actor-follow' | 7 | import { ActorFollowModel } from '../../models/actor/actor-follow' |
8 | import { areValidationErrors } from './shared' | 8 | import { areValidationErrors } from './shared' |
@@ -32,7 +32,7 @@ const userSubscriptionAddValidator = [ | |||
32 | 32 | ||
33 | const areSubscriptionsExistValidator = [ | 33 | const 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' | |||
6 | import { getServerActor } from '@server/models/application/application' | 6 | import { getServerActor } from '@server/models/application/application' |
7 | import { ExpressPromiseHandler } from '@server/types/express-handler' | 7 | import { ExpressPromiseHandler } from '@server/types/express-handler' |
8 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' | 8 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' |
9 | import { getAllPrivacies } from '@shared/core-utils' | 9 | import { arrayify, getAllPrivacies } from '@shared/core-utils' |
10 | import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude } from '@shared/models' | 10 | import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude } from '@shared/models' |
11 | import { | 11 | import { |
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 () { | |||
419 | const commonVideosFiltersValidator = [ | 418 | const 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() |