diff options
author | Wicklow <123956049+wickloww@users.noreply.github.com> | 2023-03-31 07:12:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 09:12:21 +0200 |
commit | 05a60d85997c108d39bcfb14f1ffd4c74f8b1e93 (patch) | |
tree | 5041a95ef945620a17f25ba934064b41f6bb00b7 /client | |
parent | ebd61437c1ec92bea9772924c7051cb00d71f778 (diff) | |
download | PeerTube-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 'client')
4 files changed, 29 insertions, 5 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html index fdd6b2311..b0da84979 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html | |||
@@ -272,7 +272,7 @@ | |||
272 | </div> | 272 | </div> |
273 | </div> | 273 | </div> |
274 | 274 | ||
275 | <div class="form-group" *ngIf="isSaveReplayEnabled()"> | 275 | <div class="form-group" *ngIf="isSaveReplayAllowed()"> |
276 | <my-peertube-checkbox inputName="liveVideoSaveReplay" formControlName="saveReplay"> | 276 | <my-peertube-checkbox inputName="liveVideoSaveReplay" formControlName="saveReplay"> |
277 | <ng-template ptTemplate="label"> | 277 | <ng-template ptTemplate="label"> |
278 | <ng-container i18n>Automatically publish a replay when your live ends</ng-container> | 278 | <ng-container i18n>Automatically publish a replay when your live ends</ng-container> |
@@ -284,6 +284,13 @@ | |||
284 | </my-peertube-checkbox> | 284 | </my-peertube-checkbox> |
285 | </div> | 285 | </div> |
286 | 286 | ||
287 | <div class="form-group mx-4" *ngIf="isSaveReplayEnabled()"> | ||
288 | <label i18n for="replayPrivacy">Privacy of the new replay</label> | ||
289 | <my-select-options | ||
290 | labelForId="replayPrivacy" [items]="videoPrivacies" [clearable]="false" formControlName="replayPrivacy" | ||
291 | ></my-select-options> | ||
292 | </div> | ||
293 | |||
287 | <div class="form-group" *ngIf="isLatencyModeEnabled()"> | 294 | <div class="form-group" *ngIf="isLatencyModeEnabled()"> |
288 | <label i18n for="latencyMode">Latency mode</label> | 295 | <label i18n for="latencyMode">Latency mode</label> |
289 | <my-select-options | 296 | <my-select-options |
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 89687f35e..8ed54ce6b 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts | |||
@@ -165,7 +165,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
165 | liveStreamKey: null, | 165 | liveStreamKey: null, |
166 | permanentLive: null, | 166 | permanentLive: null, |
167 | latencyMode: null, | 167 | latencyMode: null, |
168 | saveReplay: null | 168 | saveReplay: null, |
169 | replayPrivacy: null | ||
169 | } | 170 | } |
170 | 171 | ||
171 | this.formValidatorService.updateFormGroup( | 172 | this.formValidatorService.updateFormGroup( |
@@ -303,10 +304,14 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
303 | modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this)) | 304 | modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this)) |
304 | } | 305 | } |
305 | 306 | ||
306 | isSaveReplayEnabled () { | 307 | isSaveReplayAllowed () { |
307 | return this.serverConfig.live.allowReplay | 308 | return this.serverConfig.live.allowReplay |
308 | } | 309 | } |
309 | 310 | ||
311 | isSaveReplayEnabled () { | ||
312 | return this.form.value['saveReplay'] === true | ||
313 | } | ||
314 | |||
310 | isPermanentLiveEnabled () { | 315 | isPermanentLiveEnabled () { |
311 | return this.form.value['permanentLive'] === true | 316 | return this.form.value['permanentLive'] === true |
312 | } | 317 | } |
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 83a6b2229..904492994 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts | |||
@@ -8,7 +8,15 @@ import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared | |||
8 | import { LiveVideoService } from '@app/shared/shared-video-live' | 8 | import { LiveVideoService } from '@app/shared/shared-video-live' |
9 | import { LoadingBarService } from '@ngx-loading-bar/core' | 9 | import { LoadingBarService } from '@ngx-loading-bar/core' |
10 | import { logger } from '@root-helpers/logger' | 10 | import { logger } from '@root-helpers/logger' |
11 | import { LiveVideo, LiveVideoCreate, LiveVideoLatencyMode, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' | 11 | import { |
12 | LiveVideo, | ||
13 | LiveVideoCreate, | ||
14 | LiveVideoLatencyMode, | ||
15 | LiveVideoUpdate, | ||
16 | PeerTubeProblemDocument, | ||
17 | ServerErrorCode, | ||
18 | VideoPrivacy | ||
19 | } from '@shared/models' | ||
12 | import { VideoSend } from './video-send' | 20 | import { VideoSend } from './video-send' |
13 | 21 | ||
14 | @Component({ | 22 | @Component({ |
@@ -79,11 +87,12 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
79 | permanentLive: this.firstStepPermanentLive, | 87 | permanentLive: this.firstStepPermanentLive, |
80 | latencyMode: LiveVideoLatencyMode.DEFAULT, | 88 | latencyMode: LiveVideoLatencyMode.DEFAULT, |
81 | saveReplay: this.isReplayAllowed(), | 89 | saveReplay: this.isReplayAllowed(), |
90 | replaySettings: { privacy: VideoPrivacy.PRIVATE }, | ||
82 | channelId: this.firstStepChannelId | 91 | channelId: this.firstStepChannelId |
83 | } | 92 | } |
84 | 93 | ||
85 | // Go live in private mode, but correctly fill the update form with the first user choice | 94 | // Go live in private mode, but correctly fill the update form with the first user choice |
86 | const toPatch = { ...video, privacy: this.firstStepPrivacyId } | 95 | const toPatch = { ...video, privacy: this.firstStepPrivacyId, replayPrivacy: video.replaySettings.privacy } |
87 | this.form.patchValue(toPatch) | 96 | this.form.patchValue(toPatch) |
88 | 97 | ||
89 | this.liveVideoService.goLive(video) | 98 | this.liveVideoService.goLive(video) |
@@ -130,6 +139,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
130 | 139 | ||
131 | const liveVideoUpdate: LiveVideoUpdate = { | 140 | const liveVideoUpdate: LiveVideoUpdate = { |
132 | saveReplay: this.form.value.saveReplay, | 141 | saveReplay: this.form.value.saveReplay, |
142 | replaySettings: { privacy: this.form.value.replayPrivacy }, | ||
133 | latencyMode: this.form.value.latencyMode, | 143 | latencyMode: this.form.value.latencyMode, |
134 | permanentLive: this.form.value.permanentLive | 144 | permanentLive: this.form.value.permanentLive |
135 | } | 145 | } |
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index 02398a036..412b43967 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts | |||
@@ -67,6 +67,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
67 | if (this.liveVideo) { | 67 | if (this.liveVideo) { |
68 | this.form.patchValue({ | 68 | this.form.patchValue({ |
69 | saveReplay: this.liveVideo.saveReplay, | 69 | saveReplay: this.liveVideo.saveReplay, |
70 | replayPrivacy: this.liveVideo.replaySettings ? this.liveVideo.replaySettings.privacy : VideoPrivacy.PRIVATE, | ||
70 | latencyMode: this.liveVideo.latencyMode, | 71 | latencyMode: this.liveVideo.latencyMode, |
71 | permanentLive: this.liveVideo.permanentLive | 72 | permanentLive: this.liveVideo.permanentLive |
72 | }) | 73 | }) |
@@ -127,6 +128,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
127 | 128 | ||
128 | const liveVideoUpdate: LiveVideoUpdate = { | 129 | const liveVideoUpdate: LiveVideoUpdate = { |
129 | saveReplay: !!this.form.value.saveReplay, | 130 | saveReplay: !!this.form.value.saveReplay, |
131 | replaySettings: { privacy: this.form.value.replayPrivacy }, | ||
130 | permanentLive: !!this.form.value.permanentLive, | 132 | permanentLive: !!this.form.value.permanentLive, |
131 | latencyMode: this.form.value.latencyMode | 133 | latencyMode: this.form.value.latencyMode |
132 | } | 134 | } |