diff options
Diffstat (limited to 'server/controllers/api/video-playlist.ts')
-rw-r--r-- | server/controllers/api/video-playlist.ts | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 145764d35..49432d3aa 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -291,23 +291,26 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response) | |||
291 | videoId: video.id | 291 | videoId: video.id |
292 | }, { transaction: t }) | 292 | }, { transaction: t }) |
293 | 293 | ||
294 | // If the user did not set a thumbnail, automatically take the video thumbnail | 294 | videoPlaylist.updatedAt = new Date() |
295 | if (playlistElement.position === 1) { | 295 | await videoPlaylist.save({ transaction: t }) |
296 | const playlistThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoPlaylist.getThumbnailName()) | ||
297 | |||
298 | if (await pathExists(playlistThumbnailPath) === false) { | ||
299 | logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url) | ||
300 | |||
301 | const videoThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName()) | ||
302 | await copy(videoThumbnailPath, playlistThumbnailPath) | ||
303 | } | ||
304 | } | ||
305 | 296 | ||
306 | await sendUpdateVideoPlaylist(videoPlaylist, t) | 297 | await sendUpdateVideoPlaylist(videoPlaylist, t) |
307 | 298 | ||
308 | return playlistElement | 299 | return playlistElement |
309 | }) | 300 | }) |
310 | 301 | ||
302 | // If the user did not set a thumbnail, automatically take the video thumbnail | ||
303 | if (playlistElement.position === 1) { | ||
304 | const playlistThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoPlaylist.getThumbnailName()) | ||
305 | |||
306 | if (await pathExists(playlistThumbnailPath) === false) { | ||
307 | logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url) | ||
308 | |||
309 | const videoThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName()) | ||
310 | await copy(videoThumbnailPath, playlistThumbnailPath) | ||
311 | } | ||
312 | } | ||
313 | |||
311 | logger.info('Video added in playlist %s at position %d.', videoPlaylist.uuid, playlistElement.position) | 314 | logger.info('Video added in playlist %s at position %d.', videoPlaylist.uuid, playlistElement.position) |
312 | 315 | ||
313 | return res.json({ | 316 | return res.json({ |
@@ -328,6 +331,9 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re | |||
328 | 331 | ||
329 | const element = await videoPlaylistElement.save({ transaction: t }) | 332 | const element = await videoPlaylistElement.save({ transaction: t }) |
330 | 333 | ||
334 | videoPlaylist.updatedAt = new Date() | ||
335 | await videoPlaylist.save({ transaction: t }) | ||
336 | |||
331 | await sendUpdateVideoPlaylist(videoPlaylist, t) | 337 | await sendUpdateVideoPlaylist(videoPlaylist, t) |
332 | 338 | ||
333 | return element | 339 | return element |
@@ -349,6 +355,9 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo | |||
349 | // Decrease position of the next elements | 355 | // Decrease position of the next elements |
350 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t) | 356 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t) |
351 | 357 | ||
358 | videoPlaylist.updatedAt = new Date() | ||
359 | await videoPlaylist.save({ transaction: t }) | ||
360 | |||
352 | await sendUpdateVideoPlaylist(videoPlaylist, t) | 361 | await sendUpdateVideoPlaylist(videoPlaylist, t) |
353 | 362 | ||
354 | logger.info('Video playlist element %d of playlist %s deleted.', videoPlaylistElement.position, videoPlaylist.uuid) | 363 | logger.info('Video playlist element %d of playlist %s deleted.', videoPlaylistElement.position, videoPlaylist.uuid) |
@@ -390,6 +399,9 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons | |||
390 | // Decrease positions of elements after the old position of our ordered elements (decrease) | 399 | // Decrease positions of elements after the old position of our ordered elements (decrease) |
391 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t) | 400 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t) |
392 | 401 | ||
402 | videoPlaylist.updatedAt = new Date() | ||
403 | await videoPlaylist.save({ transaction: t }) | ||
404 | |||
393 | await sendUpdateVideoPlaylist(videoPlaylist, t) | 405 | await sendUpdateVideoPlaylist(videoPlaylist, t) |
394 | }) | 406 | }) |
395 | 407 | ||