ActivityPub-federated video streaming platform using P2P directly in your web browser
Be more robust with missing thumbnails/previews
Chocobozzz6872996d296d
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.tsindex 7d8296e45e..7386c2e538 100644--- a/server/lib/activitypub/videos.ts+++ b/server/lib/activitypub/videos.ts@@ -340,9 +340,11 @@ async function updateVideoFromAP (options: {if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t)- const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated)- const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)- await videoUpdated.addAndSaveThumbnail(previewModel, t)+ if (videoUpdated.getPreview()) {+ const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated)+ const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)+ await videoUpdated.addAndSaveThumbnail(previewModel, t)+ }{const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoUpdated, videoObject.url)@@ -531,6 +533,10 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAcconst video = VideoModel.build(videoData) as MVideoThumbnailconst promiseThumbnail = createVideoMiniatureFromUrl(getThumbnailFromIcons(videoObject).url, video, ThumbnailType.MINIATURE)+ .catch(err => {+ logger.error('Cannot create miniature from url.', { err })+ return undefined+ })let thumbnailModel: MThumbnailif (waitThumbnail === true) {@@ -602,11 +608,15 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc})if (waitThumbnail === false) {+ // Error is already caught above+ // eslint-disable-next-line @typescript-eslint/no-floating-promisespromiseThumbnail.then(thumbnailModel => {+ if (!thumbnailModel) return+thumbnailModel = videoCreated.idreturn thumbnailModel.save()- }).catch(err => logger.error('Cannot create miniature from url.', { err }))+ })}return { autoBlacklisted, videoCreated }diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 5964526a99..bd4ca63ea6 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -1937,6 +1937,10 @@ export class VideoModel extends Model<VideoModel> {return this.uuid + '.jpg'}+ hasPreview () {+ return !!this.getPreview()+ }+getPreview () {if (Array.isArray(this.Thumbnails) === false) return undefined