diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-12 11:40:42 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 15e9d5ca39e0b792f61453fbf3885a0fc446afa7 (patch) | |
tree | 015628bc7497f45477d287e8bb482e39d5d491e2 /server | |
parent | c5a1ae500e68b759f76851552be6dd10631d34f4 (diff) | |
download | PeerTube-15e9d5ca39e0b792f61453fbf3885a0fc446afa7.tar.gz PeerTube-15e9d5ca39e0b792f61453fbf3885a0fc446afa7.tar.zst PeerTube-15e9d5ca39e0b792f61453fbf3885a0fc446afa7.zip |
Playlist reorder support
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/video-playlist.ts | 8 | ||||
-rw-r--r-- | server/models/video/video.ts | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 49432d3aa..0a7ff92df 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -41,6 +41,7 @@ import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playli | |||
41 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | 41 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' |
42 | import { copy, pathExists } from 'fs-extra' | 42 | import { copy, pathExists } from 'fs-extra' |
43 | import { AccountModel } from '../../models/account/account' | 43 | import { AccountModel } from '../../models/account/account' |
44 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' | ||
44 | 45 | ||
45 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | 46 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) |
46 | 47 | ||
@@ -368,10 +369,11 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo | |||
368 | 369 | ||
369 | async function reorderVideosPlaylist (req: express.Request, res: express.Response) { | 370 | async function reorderVideosPlaylist (req: express.Request, res: express.Response) { |
370 | const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist | 371 | const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist |
372 | const body: VideoPlaylistReorder = req.body | ||
371 | 373 | ||
372 | const start: number = req.body.startPosition | 374 | const start: number = body.startPosition |
373 | const insertAfter: number = req.body.insertAfterPosition | 375 | const insertAfter: number = body.insertAfterPosition |
374 | const reorderLength: number = req.body.reorderLength || 1 | 376 | const reorderLength: number = body.reorderLength || 1 |
375 | 377 | ||
376 | if (start === insertAfter) { | 378 | if (start === insertAfter) { |
377 | return res.status(204).end() | 379 | return res.status(204).end() |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 06c63e87c..7624b0649 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -240,7 +240,10 @@ type AvailableForListIDsOptions = { | |||
240 | if (options.videoPlaylistId) { | 240 | if (options.videoPlaylistId) { |
241 | query.include.push({ | 241 | query.include.push({ |
242 | model: VideoPlaylistElementModel.unscoped(), | 242 | model: VideoPlaylistElementModel.unscoped(), |
243 | required: true | 243 | required: true, |
244 | where: { | ||
245 | videoPlaylistId: options.videoPlaylistId | ||
246 | } | ||
244 | }) | 247 | }) |
245 | } | 248 | } |
246 | 249 | ||
@@ -304,6 +307,8 @@ type AvailableForListIDsOptions = { | |||
304 | videoPlaylistId: options.videoPlaylistId | 307 | videoPlaylistId: options.videoPlaylistId |
305 | } | 308 | } |
306 | }) | 309 | }) |
310 | |||
311 | query.subQuery = false | ||
307 | } | 312 | } |
308 | 313 | ||
309 | if (options.filter || options.accountId || options.videoChannelId) { | 314 | if (options.filter || options.accountId || options.videoChannelId) { |