diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/sort.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 19 |
2 files changed, 8 insertions, 13 deletions
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index fcbb2902c..609046a46 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts | |||
@@ -2,6 +2,7 @@ import * as express from 'express' | |||
2 | import { SortType } from '../models/utils' | 2 | import { SortType } from '../models/utils' |
3 | 3 | ||
4 | const setDefaultSort = setDefaultSortFactory('-createdAt') | 4 | const setDefaultSort = setDefaultSortFactory('-createdAt') |
5 | const setDefaultVideosSort = setDefaultSortFactory('-publishedAt') | ||
5 | 6 | ||
6 | const setDefaultVideoRedundanciesSort = setDefaultSortFactory('name') | 7 | const setDefaultVideoRedundanciesSort = setDefaultSortFactory('name') |
7 | 8 | ||
@@ -33,6 +34,7 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex | |||
33 | export { | 34 | export { |
34 | setDefaultSort, | 35 | setDefaultSort, |
35 | setDefaultSearchSort, | 36 | setDefaultSearchSort, |
37 | setDefaultVideosSort, | ||
36 | setDefaultVideoRedundanciesSort, | 38 | setDefaultVideoRedundanciesSort, |
37 | setBlacklistSort | 39 | setBlacklistSort |
38 | } | 40 | } |
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 = [ | |||
258 | const videoPlaylistElementAPGetValidator = [ | 248 | const 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' }) |