diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/oembed.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 23 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 5 |
3 files changed, 16 insertions, 14 deletions
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index 86623efcd..2a7dc257b 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts | |||
@@ -14,7 +14,7 @@ import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-code | |||
14 | const startVideoPlaylistsURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch', 'playlist') + '/' | 14 | const startVideoPlaylistsURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch', 'playlist') + '/' |
15 | const startVideosURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/' | 15 | const startVideosURL = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/' |
16 | 16 | ||
17 | const watchRegex = new RegExp('([^/]+)$') | 17 | const watchRegex = /([^/]+)$/ |
18 | const isURLOptions = { | 18 | const isURLOptions = { |
19 | require_host: true, | 19 | require_host: true, |
20 | require_tld: true | 20 | require_tld: true |
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index c7a6f68e3..0fba4f5fd 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { ExpressPromiseHandler } from '@server/types/express' | ||
4 | import { MUserAccountId } from '@server/types/models' | ||
3 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' | 5 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' |
4 | import { logger } from '../../../helpers/logger' | 6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
5 | import { areValidationErrors } from '../utils' | 7 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
6 | import { isVideoImage } from '../../../helpers/custom-validators/videos' | 8 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' |
7 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | ||
8 | import { | 9 | import { |
9 | isArrayOf, | 10 | isArrayOf, |
10 | isIdOrUUIDValid, | 11 | isIdOrUUIDValid, |
@@ -21,15 +22,15 @@ import { | |||
21 | isVideoPlaylistTimestampValid, | 22 | isVideoPlaylistTimestampValid, |
22 | isVideoPlaylistTypeValid | 23 | isVideoPlaylistTypeValid |
23 | } from '../../../helpers/custom-validators/video-playlists' | 24 | } from '../../../helpers/custom-validators/video-playlists' |
25 | import { isVideoImage } from '../../../helpers/custom-validators/videos' | ||
24 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 26 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
25 | import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element' | 27 | import { logger } from '../../../helpers/logger' |
26 | import { authenticatePromiseIfNeeded } from '../../oauth' | ||
27 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
28 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | ||
29 | import { doesVideoChannelIdExist, doesVideoExist, doesVideoPlaylistExist, VideoPlaylistFetchType } from '../../../helpers/middlewares' | 28 | import { doesVideoChannelIdExist, doesVideoExist, doesVideoPlaylistExist, VideoPlaylistFetchType } from '../../../helpers/middlewares' |
29 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | ||
30 | import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element' | ||
30 | import { MVideoPlaylist } from '../../../types/models/video/video-playlist' | 31 | import { MVideoPlaylist } from '../../../types/models/video/video-playlist' |
31 | import { MUserAccountId } from '@server/types/models' | 32 | import { authenticatePromiseIfNeeded } from '../../oauth' |
32 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 33 | import { areValidationErrors } from '../utils' |
33 | 34 | ||
34 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ | 35 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ |
35 | body('displayName') | 36 | body('displayName') |
@@ -395,7 +396,7 @@ function getCommonPlaylistEditAttributes () { | |||
395 | body('videoChannelId') | 396 | body('videoChannelId') |
396 | .optional() | 397 | .optional() |
397 | .customSanitizer(toIntOrNull) | 398 | .customSanitizer(toIntOrNull) |
398 | ] as (ValidationChain | express.Handler)[] | 399 | ] as (ValidationChain | ExpressPromiseHandler)[] |
399 | } | 400 | } |
400 | 401 | ||
401 | function checkUserCanManageVideoPlaylist (user: MUserAccountId, videoPlaylist: MVideoPlaylist, right: UserRight, res: express.Response) { | 402 | function checkUserCanManageVideoPlaylist (user: MUserAccountId, videoPlaylist: MVideoPlaylist, right: UserRight, res: express.Response) { |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 84e309bec..26a671a1e 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -2,8 +2,10 @@ import * as express from 'express' | |||
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { isAbleToUploadVideo } from '@server/lib/user' | 3 | import { isAbleToUploadVideo } from '@server/lib/user' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | import { ExpressPromiseHandler } from '@server/types/express' | ||
5 | import { MVideoFullLight } from '@server/types/models' | 6 | import { MVideoFullLight } from '@server/types/models' |
6 | import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' | 7 | import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' |
8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
7 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' | 9 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' |
8 | import { | 10 | import { |
9 | exists, | 11 | exists, |
@@ -54,7 +56,6 @@ import { AccountModel } from '../../../models/account/account' | |||
54 | import { VideoModel } from '../../../models/video/video' | 56 | import { VideoModel } from '../../../models/video/video' |
55 | import { authenticatePromiseIfNeeded } from '../../oauth' | 57 | import { authenticatePromiseIfNeeded } from '../../oauth' |
56 | import { areValidationErrors } from '../utils' | 58 | import { areValidationErrors } from '../utils' |
57 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
58 | 59 | ||
59 | const videosAddValidator = getCommonVideoEditAttributes().concat([ | 60 | const videosAddValidator = getCommonVideoEditAttributes().concat([ |
60 | body('videofile') | 61 | body('videofile') |
@@ -411,7 +412,7 @@ function getCommonVideoEditAttributes () { | |||
411 | .optional() | 412 | .optional() |
412 | .customSanitizer(toIntOrNull) | 413 | .customSanitizer(toIntOrNull) |
413 | .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy') | 414 | .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy') |
414 | ] as (ValidationChain | express.Handler)[] | 415 | ] as (ValidationChain | ExpressPromiseHandler)[] |
415 | } | 416 | } |
416 | 417 | ||
417 | const commonVideosFiltersValidator = [ | 418 | const commonVideosFiltersValidator = [ |