diff options
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r-- | server/lib/activitypub/videos.ts | 14 |
1 files changed, 8 insertions, 6 deletions
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' | |||
29 | import { addVideoShares, shareVideoByServerAndChannel } from './share' | 29 | import { addVideoShares, shareVideoByServerAndChannel } from './share' |
30 | import { AccountModel } from '../../models/account/account' | 30 | import { AccountModel } from '../../models/account/account' |
31 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' | 31 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' |
32 | import { checkUrlsSameHost } from '../../helpers/activitypub' | 32 | import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub' |
33 | 33 | ||
34 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { | 34 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { |
35 | // If the video is not private and published, we federate it | 35 | // If the video is not private and published, we federate it |
@@ -167,7 +167,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: { | |||
167 | const refreshViews = options.refreshViews || false | 167 | const refreshViews = options.refreshViews || false |
168 | 168 | ||
169 | // Get video url | 169 | // Get video url |
170 | const videoUrl = typeof options.videoObject === 'string' ? options.videoObject : options.videoObject.id | 170 | const videoUrl = getAPUrl(options.videoObject) |
171 | 171 | ||
172 | let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) | 172 | let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) |
173 | if (videoFromDatabase) { | 173 | if (videoFromDatabase) { |
@@ -242,10 +242,6 @@ async function updateVideoFromAP (options: { | |||
242 | if (options.updateViews === true) options.video.set('views', videoData.views) | 242 | if (options.updateViews === true) options.video.set('views', videoData.views) |
243 | await options.video.save(sequelizeOptions) | 243 | await options.video.save(sequelizeOptions) |
244 | 244 | ||
245 | // Don't block on request | ||
246 | generateThumbnailFromUrl(options.video, options.videoObject.icon) | ||
247 | .catch(err => logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err })) | ||
248 | |||
249 | { | 245 | { |
250 | const videoFileAttributes = videoFileActivityUrlToDBAttributes(options.video, options.videoObject) | 246 | const videoFileAttributes = videoFileActivityUrlToDBAttributes(options.video, options.videoObject) |
251 | const newVideoFiles = videoFileAttributes.map(a => new VideoFileModel(a)) | 247 | const newVideoFiles = videoFileAttributes.map(a => new VideoFileModel(a)) |
@@ -293,6 +289,12 @@ async function updateVideoFromAP (options: { | |||
293 | logger.debug('Cannot update the remote video.', { err }) | 289 | logger.debug('Cannot update the remote video.', { err }) |
294 | throw err | 290 | throw err |
295 | } | 291 | } |
292 | |||
293 | try { | ||
294 | await generateThumbnailFromUrl(options.video, options.videoObject.icon) | ||
295 | } catch (err) { | ||
296 | logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err }) | ||
297 | } | ||
296 | } | 298 | } |
297 | 299 | ||
298 | export { | 300 | export { |