X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-format-utils.ts;h=77b8bcfe349d37d0862893f36e377ec3ef12525d;hb=684cdacbbd775b5f404dd7b373e02dd21baf5ff0;hp=92bde7773fe551f602e0e3312e5a7975ef64689b;hpb=de6310b2fcbb8a6b79c546b23dfa1920724faaa7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 92bde7773..77b8bcfe3 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -4,10 +4,10 @@ import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../shar import { MIMETYPES, WEBSERVER } from '../../initializers/constants' import { VideoCaptionModel } from './video-caption' import { - getVideoCommentsActivityPubUrl, - getVideoDislikesActivityPubUrl, - getVideoLikesActivityPubUrl, - getVideoSharesActivityPubUrl + getLocalVideoCommentsActivityPubUrl, + getLocalVideoDislikesActivityPubUrl, + getLocalVideoLikesActivityPubUrl, + getLocalVideoSharesActivityPubUrl } from '../../lib/activitypub/url' import { isArray } from '../../helpers/custom-validators/misc' import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' @@ -82,9 +82,9 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFor account: video.VideoChannel.Account.toFormattedSummaryJSON(), channel: video.VideoChannel.toFormattedSummaryJSON(), - userHistory: userHistory ? { - currentTime: userHistory.currentTime - } : undefined, + userHistory: userHistory + ? { currentTime: userHistory.currentTime } + : undefined, // Can be added by external plugins pluginData: (video as any).pluginData @@ -199,6 +199,7 @@ function videoFilesModelToFormattedJSON ( const video = extractVideo(model) return [ ...videoFiles ] + .filter(f => !f.isLive()) .sort(sortByResolutionDesc) .map(videoFile => { return { @@ -225,7 +226,9 @@ function addVideoFilesInAPAcc ( baseUrlWs: string, files: MVideoFile[] ) { - const sortedFiles = [ ...files ].sort(sortByResolutionDesc) + const sortedFiles = [ ...files ] + .filter(f => !f.isLive()) + .sort(sortByResolutionDesc) for (const file of sortedFiles) { acc.push({ @@ -352,11 +355,24 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { sensitive: video.nsfw, waitTranscoding: video.waitTranscoding, isLiveBroadcast: video.isLive, + + liveSaveReplay: video.isLive + ? video.VideoLive.saveReplay + : null, + + permanentLive: video.isLive + ? video.VideoLive.permanentLive + : null, + state: video.state, commentsEnabled: video.commentsEnabled, downloadEnabled: video.downloadEnabled, published: video.publishedAt.toISOString(), - originallyPublishedAt: video.originallyPublishedAt ? video.originallyPublishedAt.toISOString() : null, + + originallyPublishedAt: video.originallyPublishedAt + ? video.originallyPublishedAt.toISOString() + : null, + updated: video.updatedAt.toISOString(), mediaType: 'text/markdown', content: video.description, @@ -370,10 +386,10 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { height: i.height })), url, - likes: getVideoLikesActivityPubUrl(video), - dislikes: getVideoDislikesActivityPubUrl(video), - shares: getVideoSharesActivityPubUrl(video), - comments: getVideoCommentsActivityPubUrl(video), + likes: getLocalVideoLikesActivityPubUrl(video), + dislikes: getLocalVideoDislikesActivityPubUrl(video), + shares: getLocalVideoSharesActivityPubUrl(video), + comments: getLocalVideoCommentsActivityPubUrl(video), attributedTo: [ { type: 'Person',