1
0
Fork 0

Fix default privacy when plugins deleted private

This commit is contained in:
Chocobozzz 2021-07-13 08:46:51 +02:00
parent de15b052c5
commit a3f45a2ab3
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 25 additions and 6 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -15,8 +15,8 @@ export abstract class VideoSend extends FormReactive implements OnInit {
videoPrivacies: VideoConstant<VideoPrivacy>[] = []
videoCaptions: VideoCaptionEdit[] = []
firstStepPrivacyId = 0
firstStepChannelId = 0
firstStepPrivacyId: VideoPrivacy
firstStepChannelId: number
abstract firstStepDone: EventEmitter<string>
abstract firstStepError: EventEmitter<void>
@ -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)
})
}

View file

@ -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
}

View file

@ -404,6 +404,18 @@ export class VideoService implements VideosProvider {
}
}
getHighestAvailablePrivacy (serverPrivacies: VideoConstant<VideoPrivacy>[]) {
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'