aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts19
1 files changed, 6 insertions, 13 deletions
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index 07fd8533c..4647eae44 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -199,16 +199,6 @@ const videoPlaylistsAddVideoValidator = [
199 if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return 199 if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return
200 200
201 const videoPlaylist = getPlaylist(res) 201 const videoPlaylist = getPlaylist(res)
202 const video = res.locals.onlyVideo
203
204 const videoPlaylistElement = await VideoPlaylistElementModel.loadByPlaylistAndVideo(videoPlaylist.id, video.id)
205 if (videoPlaylistElement) {
206 res.status(409)
207 .json({ error: 'This video in this playlist already exists' })
208 .end()
209
210 return
211 }
212 202
213 if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, UserRight.UPDATE_ANY_VIDEO_PLAYLIST, res)) { 203 if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, UserRight.UPDATE_ANY_VIDEO_PLAYLIST, res)) {
214 return 204 return
@@ -258,15 +248,18 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
258const videoPlaylistElementAPGetValidator = [ 248const videoPlaylistElementAPGetValidator = [
259 param('playlistId') 249 param('playlistId')
260 .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id/uuid'), 250 .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id/uuid'),
261 param('videoId') 251 param('playlistElementId')
262 .custom(isIdOrUUIDValid).withMessage('Should have an video id/uuid'), 252 .custom(isIdValid).withMessage('Should have an playlist element id'),
263 253
264 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 254 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
265 logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params }) 255 logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params })
266 256
267 if (areValidationErrors(req, res)) return 257 if (areValidationErrors(req, res)) return
268 258
269 const videoPlaylistElement = await VideoPlaylistElementModel.loadByPlaylistAndVideoForAP(req.params.playlistId, req.params.videoId) 259 const playlistElementId = parseInt(req.params.playlistElementId + '', 10)
260 const playlistId = req.params.playlistId
261
262 const videoPlaylistElement = await VideoPlaylistElementModel.loadByPlaylistAndElementIdForAP(playlistId, playlistElementId)
270 if (!videoPlaylistElement) { 263 if (!videoPlaylistElement) {
271 res.status(404) 264 res.status(404)
272 .json({ error: 'Video playlist element not found' }) 265 .json({ error: 'Video playlist element not found' })