diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/videos.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 7d8296e45..7386c2e53 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -340,9 +340,11 @@ async function updateVideoFromAP (options: { | |||
340 | 340 | ||
341 | if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t) | 341 | if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t) |
342 | 342 | ||
343 | const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated) | 343 | if (videoUpdated.getPreview()) { |
344 | const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE) | 344 | const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated) |
345 | await videoUpdated.addAndSaveThumbnail(previewModel, t) | 345 | const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE) |
346 | await videoUpdated.addAndSaveThumbnail(previewModel, t) | ||
347 | } | ||
346 | 348 | ||
347 | { | 349 | { |
348 | const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoUpdated, videoObject.url) | 350 | const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoUpdated, videoObject.url) |
@@ -531,6 +533,10 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc | |||
531 | const video = VideoModel.build(videoData) as MVideoThumbnail | 533 | const video = VideoModel.build(videoData) as MVideoThumbnail |
532 | 534 | ||
533 | const promiseThumbnail = createVideoMiniatureFromUrl(getThumbnailFromIcons(videoObject).url, video, ThumbnailType.MINIATURE) | 535 | const promiseThumbnail = createVideoMiniatureFromUrl(getThumbnailFromIcons(videoObject).url, video, ThumbnailType.MINIATURE) |
536 | .catch(err => { | ||
537 | logger.error('Cannot create miniature from url.', { err }) | ||
538 | return undefined | ||
539 | }) | ||
534 | 540 | ||
535 | let thumbnailModel: MThumbnail | 541 | let thumbnailModel: MThumbnail |
536 | if (waitThumbnail === true) { | 542 | if (waitThumbnail === true) { |
@@ -602,11 +608,15 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc | |||
602 | }) | 608 | }) |
603 | 609 | ||
604 | if (waitThumbnail === false) { | 610 | if (waitThumbnail === false) { |
611 | // Error is already caught above | ||
612 | // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
605 | promiseThumbnail.then(thumbnailModel => { | 613 | promiseThumbnail.then(thumbnailModel => { |
614 | if (!thumbnailModel) return | ||
615 | |||
606 | thumbnailModel = videoCreated.id | 616 | thumbnailModel = videoCreated.id |
607 | 617 | ||
608 | return thumbnailModel.save() | 618 | return thumbnailModel.save() |
609 | }).catch(err => logger.error('Cannot create miniature from url.', { err })) | 619 | }) |
610 | } | 620 | } |
611 | 621 | ||
612 | return { autoBlacklisted, videoCreated } | 622 | return { autoBlacklisted, videoCreated } |