aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue
diff options
context:
space:
mode:
authorWicklow <123956049+wickloww@users.noreply.github.com>2023-03-31 07:12:21 +0000
committerGitHub <noreply@github.com>2023-03-31 09:12:21 +0200
commit05a60d85997c108d39bcfb14f1ffd4c74f8b1e93 (patch)
tree5041a95ef945620a17f25ba934064b41f6bb00b7 /server/lib/job-queue
parentebd61437c1ec92bea9772924c7051cb00d71f778 (diff)
downloadPeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.gz
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.zst
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.zip
Feature/Add replay privacy (#5692)
* Add replay settings feature * Fix replay settings behaviour * Fix tests * Fix tests * Fix tests * Update openapi doc and fix tests * Add tests and fix code * Models correction * Add migration and update controller and middleware * Add check params tests * Fix video live middleware * Updated code based on review comments
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index c6263f55a..2f3a971bd 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -19,6 +19,7 @@ import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@serv
19import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' 19import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
20import { logger, loggerTagsFactory } from '../../../helpers/logger' 20import { logger, loggerTagsFactory } from '../../../helpers/logger'
21import { VideoPathManager } from '@server/lib/video-path-manager' 21import { VideoPathManager } from '@server/lib/video-path-manager'
22import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting'
22 23
23const lTags = loggerTagsFactory('live', 'job') 24const lTags = loggerTagsFactory('live', 'job')
24 25
@@ -60,7 +61,13 @@ async function processVideoLiveEnding (job: Job) {
60 return cleanupLiveAndFederate({ permanentLive, video, streamingPlaylistId: payload.streamingPlaylistId }) 61 return cleanupLiveAndFederate({ permanentLive, video, streamingPlaylistId: payload.streamingPlaylistId })
61 } 62 }
62 63
63 return replaceLiveByReplay({ video, liveSession, live, permanentLive, replayDirectory: payload.replayDirectory }) 64 return replaceLiveByReplay({
65 video,
66 liveSession,
67 live,
68 permanentLive,
69 replayDirectory: payload.replayDirectory
70 })
64} 71}
65 72
66// --------------------------------------------------------------------------- 73// ---------------------------------------------------------------------------
@@ -79,6 +86,8 @@ async function saveReplayToExternalVideo (options: {
79}) { 86}) {
80 const { liveVideo, liveSession, publishedAt, replayDirectory } = options 87 const { liveVideo, liveSession, publishedAt, replayDirectory } = options
81 88
89 const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
90
82 const replayVideo = new VideoModel({ 91 const replayVideo = new VideoModel({
83 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`, 92 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
84 isLive: false, 93 isLive: false,
@@ -95,7 +104,7 @@ async function saveReplayToExternalVideo (options: {
95 nsfw: liveVideo.nsfw, 104 nsfw: liveVideo.nsfw,
96 description: liveVideo.description, 105 description: liveVideo.description,
97 support: liveVideo.support, 106 support: liveVideo.support,
98 privacy: liveVideo.privacy, 107 privacy: replaySettings.privacy,
99 channelId: liveVideo.channelId 108 channelId: liveVideo.channelId
100 }) as MVideoWithAllFiles 109 }) as MVideoWithAllFiles
101 110
@@ -142,6 +151,7 @@ async function replaceLiveByReplay (options: {
142}) { 151}) {
143 const { video, liveSession, live, permanentLive, replayDirectory } = options 152 const { video, liveSession, live, permanentLive, replayDirectory } = options
144 153
154 const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
145 const videoWithFiles = await VideoModel.loadFull(video.id) 155 const videoWithFiles = await VideoModel.loadFull(video.id)
146 const hlsPlaylist = videoWithFiles.getHLSPlaylist() 156 const hlsPlaylist = videoWithFiles.getHLSPlaylist()
147 157
@@ -150,6 +160,7 @@ async function replaceLiveByReplay (options: {
150 await live.destroy() 160 await live.destroy()
151 161
152 videoWithFiles.isLive = false 162 videoWithFiles.isLive = false
163 videoWithFiles.privacy = replaySettings.privacy
153 videoWithFiles.waitTranscoding = true 164 videoWithFiles.waitTranscoding = true
154 videoWithFiles.state = VideoState.TO_TRANSCODE 165 videoWithFiles.state = VideoState.TO_TRANSCODE
155 166