ActivityPub-federated video streaming platform using P2P directly in your web browser
Relax videos list thumbnail api join
Chocobozzz2fb5b3a55aee
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.tsindex d818c459c6..76b744de85 100644--- a/server/helpers/ffmpeg-utils.ts+++ b/server/helpers/ffmpeg-utils.ts@@ -105,7 +105,7 @@ async function generateImageFromVideoFile (fromPath: string, folder: string, ima})const destination = join(folder, imageName)- await processImage({ path: pendingImagePath }, destination, size)+ await processImage(pendingImagePath, destination, size)} catch (err) {logger.error('Cannot generate image from video %s.', fromPath, { err })diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.tsindex eeaef0f5d3..bd81aa3bad 100644--- a/server/helpers/image-utils.ts+++ b/server/helpers/image-utils.ts@@ -4,19 +4,19 @@ import { readFile, remove } from 'fs-extra'import { logger } from './logger'async function processImage (- physicalFile: { path: string },+ path: string,destination: string,newSize: { width: number, height: number },keepOriginal = false) {- if (physicalFile.path === destination) {+ if (path === destination) {throw new Error('Sharp needs an input path different that the output path.')}- logger.debug('Processing image %s to %s.', physicalFile.path, destination)+ logger.debug('Processing image %s to %s.', path, destination)// Avoid sharp cache- const buf = await readFile(physicalFile.path)+ const buf = await readFile(path)const sharpInstance = sharp(buf)await remove(destination)@@ -25,7 +25,7 @@ async function processImage (.resize(newSize.width, newSize.height).toFile(destination)- if (keepOriginal !== true) await remove(physicalFile.path)+ if (keepOriginal !== true) await remove(path)}// ---------------------------------------------------------------------------diff --git a/server/helpers/requests.ts b/server/helpers/requests.tsindex 8dda6c039c..2e30c94a1e 100644--- a/server/helpers/requests.ts+++ b/server/helpers/requests.ts@@ -52,7 +52,7 @@ async function downloadImage (url: string, destDir: string, destName: string, siconst destPath = join(destDir, destName)try {- await processImage({ path: tmpPath }, destPath, size)+ await processImage(tmpPath, destPath, size)} catch (err) {await remove(tmpPath)diff --git a/server/lib/avatar.ts b/server/lib/avatar.tsindex dca543d0b9..09b4e38ca1 100644--- a/server/lib/avatar.ts+++ b/server/lib/avatar.ts@@ -15,7 +15,7 @@ async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, aconst extension = extname(avatarPhysicalFile.filename)const avatarName = uuidv4() + extensionconst destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)- await processImage(avatarPhysicalFile, destination, AVATARS_SIZE)+ await processImage(avatarPhysicalFile.path, destination, AVATARS_SIZE)return retryTransactionWrapper(() => {return sequelizeTypescript.transaction(async t => {diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.tsindex 8ad82ee800..4ba521b973 100644--- a/server/lib/thumbnail.ts+++ b/server/lib/thumbnail.ts@@ -16,7 +16,7 @@ function createPlaylistMiniatureFromExisting (inputPath: string, playlist: Videoconst { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size)const type = ThumbnailType.MINIATURE- const thumbnailCreator = () => processImage({ path: inputPath }, outputPath, { width, height }, keepOriginal)+ const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal)return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail })}@@ -37,7 +37,7 @@ function createVideoMiniatureFromUrl (url: string, video: VideoModel, type: Thumfunction createVideoMiniatureFromExisting (inputPath: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) {const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)- const thumbnailCreator = () => processImage({ path: inputPath }, outputPath, { width, height })+ const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height })return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail })}diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 18f18795ed..5fb529e8d1 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -239,6 +239,11 @@ type AvailableForListIDsOptions = {{model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }),required: true+ },+ {+ attributes: [ 'type', 'filename' ],+ model: ThumbnailModel,+ required: false}]}@@ -1599,7 +1604,7 @@ export class VideoModel extends Model<VideoModel> {]}- const apiScope: (string | ScopeOptions)[] = [ ScopeNames.WITH_THUMBNAILS ]+ const apiScope: (string | ScopeOptions)[] = []if (options.user) {apiScope.push({ method: [ ScopeNames.WITH_USER_HISTORY, options.user.id ] })