]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-format-utils.ts
client(hotkeys): remove seekstep VLC behavior
[github/Chocobozzz/PeerTube.git] / server / models / video / video-format-utils.ts
index 92bde7773fe551f602e0e3312e5a7975ef64689b..77b8bcfe349d37d0862893f36e377ec3ef12525d 100644 (file)
@@ -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',