diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-06 17:29:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-06 17:29:15 +0200 |
commit | 1b319b7aa6d2f4252615b370aaca6a800be1b1f4 (patch) | |
tree | 1d7eed8c392423aa578c609fe269832c5ac99b17 /server/middlewares/validators/videos | |
parent | 46a6db245f50249246325090eeaffd165453a396 (diff) | |
download | PeerTube-1b319b7aa6d2f4252615b370aaca6a800be1b1f4.tar.gz PeerTube-1b319b7aa6d2f4252615b370aaca6a800be1b1f4.tar.zst PeerTube-1b319b7aa6d2f4252615b370aaca6a800be1b1f4.zip |
Add ability to unpublish video/playlist
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index f68eeeeb3..9c88dd291 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -24,6 +24,9 @@ import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/ | |||
24 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | 24 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' |
25 | 25 | ||
26 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ | 26 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ |
27 | body('displayName') | ||
28 | .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), | ||
29 | |||
27 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 30 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
28 | logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }) | 31 | logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }) |
29 | 32 | ||
@@ -46,6 +49,10 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([ | |||
46 | param('playlistId') | 49 | param('playlistId') |
47 | .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id/uuid'), | 50 | .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id/uuid'), |
48 | 51 | ||
52 | body('displayName') | ||
53 | .optional() | ||
54 | .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), | ||
55 | |||
49 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 56 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
50 | logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }) | 57 | logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }) |
51 | 58 | ||
@@ -61,12 +68,6 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([ | |||
61 | 68 | ||
62 | const body: VideoPlaylistUpdate = req.body | 69 | const body: VideoPlaylistUpdate = req.body |
63 | 70 | ||
64 | if (videoPlaylist.privacy !== VideoPlaylistPrivacy.PRIVATE && body.privacy === VideoPlaylistPrivacy.PRIVATE) { | ||
65 | cleanUpReqFiles(req) | ||
66 | return res.status(400) | ||
67 | .json({ error: 'Cannot set "private" a video playlist that was not private.' }) | ||
68 | } | ||
69 | |||
70 | const newPrivacy = body.privacy || videoPlaylist.privacy | 71 | const newPrivacy = body.privacy || videoPlaylist.privacy |
71 | if (newPrivacy === VideoPlaylistPrivacy.PUBLIC && | 72 | if (newPrivacy === VideoPlaylistPrivacy.PUBLIC && |
72 | ( | 73 | ( |
@@ -368,8 +369,6 @@ function getCommonPlaylistEditAttributes () { | |||
368 | + CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.IMAGE.EXTNAME.join(', ') | 369 | + CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.IMAGE.EXTNAME.join(', ') |
369 | ), | 370 | ), |
370 | 371 | ||
371 | body('displayName') | ||
372 | .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), | ||
373 | body('description') | 372 | body('description') |
374 | .optional() | 373 | .optional() |
375 | .customSanitizer(toValueOrNull) | 374 | .customSanitizer(toValueOrNull) |