X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fformatter%2Fvideo-format-utils.ts;h=6f05dbdc8bf2008126d85d1d1b99418593daf604;hb=32fde390f465b9ceef9e49c4037acdacbe176d65;hp=e1b0eb6108e00d8a131044d92a502ba0fccf65a2;hpb=12d84abeca4917d2f1e3f308010bfcd56d37cb7c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index e1b0eb610..6f05dbdc8 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts @@ -34,6 +34,7 @@ import { import { MServer, MStreamingPlaylistRedundanciesOpt, + MUserId, MVideo, MVideoAP, MVideoFile, @@ -57,7 +58,7 @@ export type VideoFormattingJSONOptions = { } function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSanitize): VideoFormattingJSONOptions { - if (!query || !query.include) return {} + if (!query?.include) return {} return { additionalAttributes: { @@ -102,6 +103,7 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm }, nsfw: video.nsfw, + truncatedDescription: video.getTruncatedDescription(), description: options && options.completeDescription === true ? video.description : video.getTruncatedDescription(), @@ -180,6 +182,7 @@ function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): Vid const span = tracer.startSpan('peertube.VideoModel.toFormattedDetailsJSON') const videoJSON = video.toFormattedJSON({ + completeDescription: true, additionalAttributes: { scheduledUpdate: true, blacklistInfo: true, @@ -245,8 +248,12 @@ function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) { function videoFilesModelToFormattedJSON ( video: MVideoFormattable, videoFiles: MVideoFileRedundanciesOpt[], - includeMagnet = true + options: { + includeMagnet?: boolean // default true + } = {} ): VideoFile[] { + const { includeMagnet = true } = options + const trackerUrls = includeMagnet ? video.getTrackerUrls() : [] @@ -281,11 +288,14 @@ function videoFilesModelToFormattedJSON ( }) } -function addVideoFilesInAPAcc ( - acc: ActivityUrlObject[] | ActivityTagObject[], - video: MVideo, +function addVideoFilesInAPAcc (options: { + acc: ActivityUrlObject[] | ActivityTagObject[] + video: MVideo files: MVideoFile[] -) { + user?: MUserId +}) { + const { acc, video, files } = options + const trackerUrls = video.getTrackerUrls() const sortedFiles = (files || []) @@ -370,7 +380,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { } ] - addVideoFilesInAPAcc(url, video, video.VideoFiles || []) + addVideoFilesInAPAcc({ acc: url, video, files: video.VideoFiles || [] }) for (const playlist of (video.VideoStreamingPlaylists || [])) { const tag = playlist.p2pMediaLoaderInfohashes @@ -382,7 +392,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { href: playlist.getSha256SegmentsUrl(video) }) - addVideoFilesInAPAcc(tag, video, playlist.VideoFiles || []) + addVideoFilesInAPAcc({ acc: tag, video, files: playlist.VideoFiles || [] }) url.push({ type: 'Link', @@ -478,7 +488,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { } function getCategoryLabel (id: number) { - return VIDEO_CATEGORIES[id] || 'Misc' + return VIDEO_CATEGORIES[id] || 'Unknown' } function getLicenceLabel (id: number) {