aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index 22b8b8ff1..87d2c7b51 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -4,9 +4,9 @@ import { UserRight } from '../../../../shared'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { UserModel } from '../../../models/account/user' 5import { UserModel } from '../../../models/account/user'
6import { areValidationErrors } from '../utils' 6import { areValidationErrors } from '../utils'
7import { isVideoExist, isVideoImage } from '../../../helpers/custom-validators/videos' 7import { isVideoExist, isVideoFileInfoHashValid, isVideoImage } from '../../../helpers/custom-validators/videos'
8import { CONSTRAINTS_FIELDS } from '../../../initializers' 8import { CONSTRAINTS_FIELDS } from '../../../initializers'
9import { isIdOrUUIDValid, isUUIDValid, toValueOrNull } from '../../../helpers/custom-validators/misc' 9import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toArray, toValueOrNull, toIntArray } from '../../../helpers/custom-validators/misc'
10import { 10import {
11 isVideoPlaylistDescriptionValid, 11 isVideoPlaylistDescriptionValid,
12 isVideoPlaylistExist, 12 isVideoPlaylistExist,
@@ -23,6 +23,7 @@ import { VideoModel } from '../../../models/video/video'
23import { authenticatePromiseIfNeeded } from '../../oauth' 23import { authenticatePromiseIfNeeded } from '../../oauth'
24import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' 24import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
25import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' 25import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
26import { areValidActorHandles } from '../../../helpers/custom-validators/activitypub/actor'
26 27
27const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ 28const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
28 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 29 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
@@ -305,6 +306,20 @@ const commonVideoPlaylistFiltersValidator = [
305 } 306 }
306] 307]
307 308
309const doVideosInPlaylistExistValidator = [
310 query('videoIds')
311 .customSanitizer(toIntArray)
312 .custom(v => isArrayOf(v, isIdValid)).withMessage('Should have a valid video ids array'),
313
314 (req: express.Request, res: express.Response, next: express.NextFunction) => {
315 logger.debug('Checking areVideosInPlaylistExistValidator parameters', { parameters: req.query })
316
317 if (areValidationErrors(req, res)) return
318
319 return next()
320 }
321]
322
308// --------------------------------------------------------------------------- 323// ---------------------------------------------------------------------------
309 324
310export { 325export {
@@ -319,7 +334,9 @@ export {
319 334
320 videoPlaylistElementAPGetValidator, 335 videoPlaylistElementAPGetValidator,
321 336
322 commonVideoPlaylistFiltersValidator 337 commonVideoPlaylistFiltersValidator,
338
339 doVideosInPlaylistExistValidator
323} 340}
324 341
325// --------------------------------------------------------------------------- 342// ---------------------------------------------------------------------------