aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/videos.ts18
1 files changed, 10 insertions, 8 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 8545e5bad..b5a199e67 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -5,6 +5,7 @@ import { join } from 'path'
5import * as request from 'request' 5import * as request from 'request'
6import * as sequelize from 'sequelize' 6import * as sequelize from 'sequelize'
7import { VideoLiveModel } from '@server/models/video/video-live' 7import { VideoLiveModel } from '@server/models/video/video-live'
8import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
8import { 9import {
9 ActivityHashTagObject, 10 ActivityHashTagObject,
10 ActivityMagnetUrlObject, 11 ActivityMagnetUrlObject,
@@ -15,7 +16,7 @@ import {
15 ActivityUrlObject, 16 ActivityUrlObject,
16 ActivityVideoUrlObject 17 ActivityVideoUrlObject
17} from '../../../shared/index' 18} from '../../../shared/index'
18import { VideoObject } from '../../../shared/models/activitypub/objects' 19import { ActivityIconObject, VideoObject } from '../../../shared/models/activitypub/objects'
19import { VideoPrivacy } from '../../../shared/models/videos' 20import { VideoPrivacy } from '../../../shared/models/videos'
20import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' 21import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
21import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' 22import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
@@ -76,7 +77,6 @@ import { sendCreateVideo, sendUpdateVideo } from './send'
76import { addVideoShares, shareVideoByServerAndChannel } from './share' 77import { addVideoShares, shareVideoByServerAndChannel } from './share'
77import { addVideoComments } from './video-comments' 78import { addVideoComments } from './video-comments'
78import { createRates } from './video-rates' 79import { createRates } from './video-rates'
79import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
80 80
81async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVideo: boolean, transaction?: sequelize.Transaction) { 81async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVideo: boolean, transaction?: sequelize.Transaction) {
82 const video = videoArg as MVideoAP 82 const video = videoArg as MVideoAP
@@ -360,7 +360,7 @@ async function updateVideoFromAP (options: {
360 if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t) 360 if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t)
361 361
362 if (videoUpdated.getPreview()) { 362 if (videoUpdated.getPreview()) {
363 const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated) 363 const previewUrl = getPreviewUrl(getPreviewFromIcons(videoObject), video)
364 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE) 364 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
365 await videoUpdated.addAndSaveThumbnail(previewModel, t) 365 await videoUpdated.addAndSaveThumbnail(previewModel, t)
366 } 366 }
@@ -597,9 +597,7 @@ async function createVideo (videoObject: VideoObject, channel: MChannelAccountLi
597 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) 597 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t)
598 598
599 const previewIcon = getPreviewFromIcons(videoObject) 599 const previewIcon = getPreviewFromIcons(videoObject)
600 const previewUrl = previewIcon 600 const previewUrl = getPreviewUrl(previewIcon, videoCreated)
601 ? previewIcon.url
602 : buildRemoteVideoBaseUrl(videoCreated, join(STATIC_PATHS.PREVIEWS, video.generatePreviewName()))
603 const previewModel = createPlaceholderThumbnail(previewUrl, videoCreated, ThumbnailType.PREVIEW, PREVIEWS_SIZE) 601 const previewModel = createPlaceholderThumbnail(previewUrl, videoCreated, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
604 602
605 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(previewModel, t) 603 if (thumbnailModel) await videoCreated.addAndSaveThumbnail(previewModel, t)
@@ -822,7 +820,11 @@ function getThumbnailFromIcons (videoObject: VideoObject) {
822function getPreviewFromIcons (videoObject: VideoObject) { 820function getPreviewFromIcons (videoObject: VideoObject) {
823 const validIcons = videoObject.icon.filter(i => i.width > PREVIEWS_SIZE.minWidth) 821 const validIcons = videoObject.icon.filter(i => i.width > PREVIEWS_SIZE.minWidth)
824 822
825 // FIXME: don't put a fallback here for compatibility with PeerTube <2.2
826
827 return maxBy(validIcons, 'width') 823 return maxBy(validIcons, 'width')
828} 824}
825
826function getPreviewUrl (previewIcon: ActivityIconObject, video: MVideoAccountLight) {
827 return previewIcon
828 ? previewIcon.url
829 : buildRemoteVideoBaseUrl(video, join(STATIC_PATHS.PREVIEWS, video.generatePreviewName()))
830}