diff options
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r-- | server/lib/activitypub/videos.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index b5a199e67..201ef0302 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -56,6 +56,7 @@ import { | |||
56 | MVideoAccountLightBlacklistAllFiles, | 56 | MVideoAccountLightBlacklistAllFiles, |
57 | MVideoAP, | 57 | MVideoAP, |
58 | MVideoAPWithoutCaption, | 58 | MVideoAPWithoutCaption, |
59 | MVideoCaption, | ||
59 | MVideoFile, | 60 | MVideoFile, |
60 | MVideoFullLight, | 61 | MVideoFullLight, |
61 | MVideoId, | 62 | MVideoId, |
@@ -90,7 +91,7 @@ async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVid | |||
90 | // Fetch more attributes that we will need to serialize in AP object | 91 | // Fetch more attributes that we will need to serialize in AP object |
91 | if (isArray(video.VideoCaptions) === false) { | 92 | if (isArray(video.VideoCaptions) === false) { |
92 | video.VideoCaptions = await video.$get('VideoCaptions', { | 93 | video.VideoCaptions = await video.$get('VideoCaptions', { |
93 | attributes: [ 'language' ], | 94 | attributes: [ 'filename', 'language' ], |
94 | transaction | 95 | transaction |
95 | }) | 96 | }) |
96 | } | 97 | } |
@@ -423,7 +424,14 @@ async function updateVideoFromAP (options: { | |||
423 | await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(videoUpdated.id, t) | 424 | await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(videoUpdated.id, t) |
424 | 425 | ||
425 | const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { | 426 | const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { |
426 | return VideoCaptionModel.insertOrReplaceLanguage(videoUpdated.id, c.identifier, c.url, t) | 427 | const caption = new VideoCaptionModel({ |
428 | videoId: videoUpdated.id, | ||
429 | filename: VideoCaptionModel.generateCaptionName(c.identifier), | ||
430 | language: c.identifier, | ||
431 | fileUrl: c.url | ||
432 | }) as MVideoCaption | ||
433 | |||
434 | return VideoCaptionModel.insertOrReplaceLanguage(caption, t) | ||
427 | }) | 435 | }) |
428 | await Promise.all(videoCaptionsPromises) | 436 | await Promise.all(videoCaptionsPromises) |
429 | } | 437 | } |
@@ -629,7 +637,14 @@ async function createVideo (videoObject: VideoObject, channel: MChannelAccountLi | |||
629 | 637 | ||
630 | // Process captions | 638 | // Process captions |
631 | const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { | 639 | const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { |
632 | return VideoCaptionModel.insertOrReplaceLanguage(videoCreated.id, c.identifier, c.url, t) | 640 | const caption = new VideoCaptionModel({ |
641 | videoId: videoCreated.id, | ||
642 | filename: VideoCaptionModel.generateCaptionName(c.identifier), | ||
643 | language: c.identifier, | ||
644 | fileUrl: c.url | ||
645 | }) as MVideoCaption | ||
646 | |||
647 | return VideoCaptionModel.insertOrReplaceLanguage(caption, t) | ||
633 | }) | 648 | }) |
634 | await Promise.all(videoCaptionsPromises) | 649 | await Promise.all(videoCaptionsPromises) |
635 | 650 | ||