diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-07 17:06:00 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | f0a3988066f72a28bb44520af072f18d91d77dde (patch) | |
tree | dfa3a92102557b567530c5dd014c90866621140a /server/middlewares | |
parent | 830b4faff15fb9c81d88e8e69fcdf94aad32bef8 (diff) | |
download | PeerTube-f0a3988066f72a28bb44520af072f18d91d77dde.tar.gz PeerTube-f0a3988066f72a28bb44520af072f18d91d77dde.tar.zst PeerTube-f0a3988066f72a28bb44520af072f18d91d77dde.zip |
Add to playlist dropdown
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 23 |
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' | |||
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { UserModel } from '../../../models/account/user' | 5 | import { UserModel } from '../../../models/account/user' |
6 | import { areValidationErrors } from '../utils' | 6 | import { areValidationErrors } from '../utils' |
7 | import { isVideoExist, isVideoImage } from '../../../helpers/custom-validators/videos' | 7 | import { isVideoExist, isVideoFileInfoHashValid, isVideoImage } from '../../../helpers/custom-validators/videos' |
8 | import { CONSTRAINTS_FIELDS } from '../../../initializers' | 8 | import { CONSTRAINTS_FIELDS } from '../../../initializers' |
9 | import { isIdOrUUIDValid, isUUIDValid, toValueOrNull } from '../../../helpers/custom-validators/misc' | 9 | import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toArray, toValueOrNull, toIntArray } from '../../../helpers/custom-validators/misc' |
10 | import { | 10 | import { |
11 | isVideoPlaylistDescriptionValid, | 11 | isVideoPlaylistDescriptionValid, |
12 | isVideoPlaylistExist, | 12 | isVideoPlaylistExist, |
@@ -23,6 +23,7 @@ import { VideoModel } from '../../../models/video/video' | |||
23 | import { authenticatePromiseIfNeeded } from '../../oauth' | 23 | import { authenticatePromiseIfNeeded } from '../../oauth' |
24 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 24 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
25 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | 25 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' |
26 | import { areValidActorHandles } from '../../../helpers/custom-validators/activitypub/actor' | ||
26 | 27 | ||
27 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ | 28 | const 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 | ||
309 | const 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 | ||
310 | export { | 325 | export { |
@@ -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 | // --------------------------------------------------------------------------- |