]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/video-playlist.ts
Fix notification scrollbar color
[github/Chocobozzz/PeerTube.git] / server / controllers / api / video-playlist.ts
index fb08a63b213fbf30d43e2f951057f62b039c32af..aab16533d15844e3160ff9f1329f58024ad644fe 100644 (file)
@@ -42,6 +42,7 @@ import {
 import { AccountModel } from '../../models/account/account'
 import { VideoPlaylistModel } from '../../models/video/video-playlist'
 import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
 const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR })
 
@@ -172,7 +173,11 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
 
   const thumbnailField = req.files['thumbnailfile']
   const thumbnailModel = thumbnailField
-    ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylist, false)
+    ? await createPlaylistMiniatureFromExisting({
+      inputPath: thumbnailField[0].path,
+      playlist: videoPlaylist,
+      automaticallyGenerated: false
+    })
     : undefined
 
   const videoPlaylistCreated = await sequelizeTypescript.transaction(async t => {
@@ -210,7 +215,11 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
 
   const thumbnailField = req.files['thumbnailfile']
   const thumbnailModel = thumbnailField
-    ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylistInstance, false)
+    ? await createPlaylistMiniatureFromExisting({
+      inputPath: thumbnailField[0].path,
+      playlist: videoPlaylistInstance,
+      automaticallyGenerated: false
+    })
     : undefined
 
   try {
@@ -271,7 +280,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
     throw err
   }
 
-  return res.type('json').status(204).end()
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function removeVideoPlaylist (req: express.Request, res: express.Response) {
@@ -285,7 +294,7 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response)
     logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid)
   })
 
-  return res.type('json').status(204).end()
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function addVideoInPlaylist (req: express.Request, res: express.Response) {
@@ -351,7 +360,7 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re
 
   logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid)
 
-  return res.type('json').status(204).end()
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function removeVideoFromPlaylist (req: express.Request, res: express.Response) {
@@ -379,7 +388,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo
   sendUpdateVideoPlaylist(videoPlaylist, undefined)
     .catch(err => logger.error('Cannot send video playlist update.', { err }))
 
-  return res.type('json').status(204).end()
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function reorderVideosPlaylist (req: express.Request, res: express.Response) {
@@ -391,7 +400,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
   const reorderLength: number = body.reorderLength || 1
 
   if (start === insertAfter) {
-    return res.status(204).end()
+    return res.status(HttpStatusCode.NO_CONTENT_204).end()
   }
 
   // Example: if we reorder position 2 and insert after position 5 (so at position 6): # 1 2 3 4 5 6 7 8 9
@@ -432,7 +441,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons
     videoPlaylist.uuid, insertAfter, start, start + reorderLength - 1
   )
 
-  return res.type('json').status(204).end()
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function getVideoPlaylistVideos (req: express.Request, res: express.Response) {
@@ -473,7 +482,12 @@ async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbn
   }
 
   const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
-  const thumbnailModel = await createPlaylistMiniatureFromExisting(inputPath, videoPlaylist, true, true)
+  const thumbnailModel = await createPlaylistMiniatureFromExisting({
+    inputPath,
+    playlist: videoPlaylist,
+    automaticallyGenerated: true,
+    keepOriginal: true
+  })
 
   thumbnailModel.videoPlaylistId = videoPlaylist.id