X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fvideos.ts;h=4cecf9345912a6d08eb59b73d13a6de183b20036;hb=361805c48b14c5402c9984485c67c45a1a3113cc;hp=80de92f244d6c1ceecf1d3067eaa80b2345fdc3e;hpb=58d515e32fe1d0133435b3a5e550c6ff24906fff;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 80de92f24..4cecf9345 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -29,7 +29,7 @@ import { createRates } from './video-rates' import { addVideoShares, shareVideoByServerAndChannel } from './share' import { AccountModel } from '../../models/account/account' import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' -import { checkUrlsSameHost } from '../../helpers/activitypub' +import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub' async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { // If the video is not private and published, we federate it @@ -167,7 +167,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: { const refreshViews = options.refreshViews || false // Get video url - const videoUrl = typeof options.videoObject === 'string' ? options.videoObject : options.videoObject.id + const videoUrl = getAPUrl(options.videoObject) let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) if (videoFromDatabase) { @@ -242,10 +242,6 @@ async function updateVideoFromAP (options: { if (options.updateViews === true) options.video.set('views', videoData.views) await options.video.save(sequelizeOptions) - // Don't block on request - generateThumbnailFromUrl(options.video, options.videoObject.icon) - .catch(err => logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err })) - { const videoFileAttributes = videoFileActivityUrlToDBAttributes(options.video, options.videoObject) const newVideoFiles = videoFileAttributes.map(a => new VideoFileModel(a)) @@ -293,6 +289,12 @@ async function updateVideoFromAP (options: { logger.debug('Cannot update the remote video.', { err }) throw err } + + try { + await generateThumbnailFromUrl(options.video, options.videoObject.icon) + } catch (err) { + logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err }) + } } export {