From a3f45a2ab3cadf0946f06a0539993b828becd516 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 08:46:51 +0200 Subject: Fix default privacy when plugins deleted private --- .../app/+videos/+video-edit/shared/video-edit.component.ts | 1 + .../video-add-components/video-go-live.component.ts | 2 +- .../video-add-components/video-import-torrent.component.ts | 2 +- .../video-add-components/video-import-url.component.ts | 2 +- .../+videos/+video-edit/video-add-components/video-send.ts | 10 ++++++++-- .../video-add-components/video-upload.component.ts | 2 +- client/src/app/shared/shared-main/video/video.service.ts | 12 ++++++++++++ 7 files changed, 25 insertions(+), 6 deletions(-) (limited to 'client/src/app') 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 aebd53318..90a0e8f52 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 @@ -185,6 +185,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { this.serverService.getVideoPrivacies() .subscribe(privacies => { this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies + if (this.schedulePublicationPossible) { this.videoPrivacies.push({ id: this.SPECIAL_SCHEDULED_PRIVACY, 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 01c9fcb16..db25dc6be 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 @@ -62,7 +62,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView const video: LiveVideoCreate = { name, - privacy: VideoPrivacy.PRIVATE, + privacy: this.highestPrivacy, nsfw: this.serverConfig.instance.isNSFW, waitTranscoding: true, commentsEnabled: true, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index 172dd5ba5..62aaeb019 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -79,7 +79,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af this.isImportingVideo = true const videoUpdate: VideoUpdate = { - privacy: VideoPrivacy.PRIVATE, + privacy: this.highestPrivacy, waitTranscoding: false, commentsEnabled: true, downloadEnabled: true, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts index 2994d05fa..3243b4d38 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts @@ -66,7 +66,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV this.isImportingVideo = true const videoUpdate: VideoUpdate = { - privacy: VideoPrivacy.PRIVATE, + privacy: this.highestPrivacy, waitTranscoding: false, commentsEnabled: true, downloadEnabled: true, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index 0e7a26a47..ce8de049d 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts @@ -15,8 +15,8 @@ export abstract class VideoSend extends FormReactive implements OnInit { videoPrivacies: VideoConstant[] = [] videoCaptions: VideoCaptionEdit[] = [] - firstStepPrivacyId = 0 - firstStepChannelId = 0 + firstStepPrivacyId: VideoPrivacy + firstStepChannelId: number abstract firstStepDone: EventEmitter abstract firstStepError: EventEmitter @@ -24,11 +24,15 @@ export abstract class VideoSend extends FormReactive implements OnInit { protected loadingBar: LoadingBarService protected notifier: Notifier protected authService: AuthService + protected serverService: ServerService protected videoService: VideoService protected videoCaptionService: VideoCaptionService + protected serverConfig: HTMLServerConfig + protected highestPrivacy: VideoPrivacy + abstract canDeactivate (): CanComponentDeactivateResult ngOnInit () { @@ -49,6 +53,8 @@ export abstract class VideoSend extends FormReactive implements OnInit { this.videoPrivacies = videoPrivacies this.firstStepPrivacyId = defaultPrivacyId + + this.highestPrivacy = this.videoService.getHighestAvailablePrivacy(privacies) }) } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index ec027f257..627de33c0 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -265,7 +265,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy downloadEnabled: true, channelId: this.firstStepChannelId, nsfw: this.serverConfig.instance.isNSFW, - privacy: VideoPrivacy.PRIVATE.toString(), + privacy: this.highestPrivacy.toString(), filename: file.name, previewfile: previewfile as any } diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 1c1d06291..49d6fc1c7 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -404,6 +404,18 @@ export class VideoService implements VideosProvider { } } + getHighestAvailablePrivacy (serverPrivacies: VideoConstant[]) { + const order = [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL, VideoPrivacy.UNLISTED, VideoPrivacy.PUBLIC ] + + for (const privacy of order) { + if (serverPrivacies.find(p => p.id === privacy)) { + return privacy + } + } + + throw new Error('No highest privacy available') + } + nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) { return nsfwPolicy === 'do_not_list' ? 'false' -- cgit v1.2.3