diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/videos.ts | 18 |
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' | |||
5 | import * as request from 'request' | 5 | import * as request from 'request' |
6 | import * as sequelize from 'sequelize' | 6 | import * as sequelize from 'sequelize' |
7 | import { VideoLiveModel } from '@server/models/video/video-live' | 7 | import { VideoLiveModel } from '@server/models/video/video-live' |
8 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
8 | import { | 9 | import { |
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' |
18 | import { VideoObject } from '../../../shared/models/activitypub/objects' | 19 | import { ActivityIconObject, VideoObject } from '../../../shared/models/activitypub/objects' |
19 | import { VideoPrivacy } from '../../../shared/models/videos' | 20 | import { VideoPrivacy } from '../../../shared/models/videos' |
20 | import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' | 21 | import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' |
21 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' | 22 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' |
@@ -76,7 +77,6 @@ import { sendCreateVideo, sendUpdateVideo } from './send' | |||
76 | import { addVideoShares, shareVideoByServerAndChannel } from './share' | 77 | import { addVideoShares, shareVideoByServerAndChannel } from './share' |
77 | import { addVideoComments } from './video-comments' | 78 | import { addVideoComments } from './video-comments' |
78 | import { createRates } from './video-rates' | 79 | import { createRates } from './video-rates' |
79 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
80 | 80 | ||
81 | async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVideo: boolean, transaction?: sequelize.Transaction) { | 81 | async 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) { | |||
822 | function getPreviewFromIcons (videoObject: VideoObject) { | 820 | function 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 | |||
826 | function getPreviewUrl (previewIcon: ActivityIconObject, video: MVideoAccountLight) { | ||
827 | return previewIcon | ||
828 | ? previewIcon.url | ||
829 | : buildRemoteVideoBaseUrl(video, join(STATIC_PATHS.PREVIEWS, video.generatePreviewName())) | ||
830 | } | ||