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() this.serverService.getVideoPrivacies()
.subscribe(privacies => { .subscribe(privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
if (this.schedulePublicationPossible) { if (this.schedulePublicationPossible) {
this.videoPrivacies.push({ this.videoPrivacies.push({
id: this.SPECIAL_SCHEDULED_PRIVACY, id: this.SPECIAL_SCHEDULED_PRIVACY,

View file

@ -62,7 +62,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
const video: LiveVideoCreate = { const video: LiveVideoCreate = {
name, name,
privacy: VideoPrivacy.PRIVATE, privacy: this.highestPrivacy,
nsfw: this.serverConfig.instance.isNSFW, nsfw: this.serverConfig.instance.isNSFW,
waitTranscoding: true, waitTranscoding: true,
commentsEnabled: true, commentsEnabled: true,

View file

@ -79,7 +79,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
this.isImportingVideo = true this.isImportingVideo = true
const videoUpdate: VideoUpdate = { const videoUpdate: VideoUpdate = {
privacy: VideoPrivacy.PRIVATE, privacy: this.highestPrivacy,
waitTranscoding: false, waitTranscoding: false,
commentsEnabled: true, commentsEnabled: true,
downloadEnabled: true, downloadEnabled: true,

View file

@ -66,7 +66,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
this.isImportingVideo = true this.isImportingVideo = true
const videoUpdate: VideoUpdate = { const videoUpdate: VideoUpdate = {
privacy: VideoPrivacy.PRIVATE, privacy: this.highestPrivacy,
waitTranscoding: false, waitTranscoding: false,
commentsEnabled: true, commentsEnabled: true,
downloadEnabled: true, downloadEnabled: true,

View file

@ -15,8 +15,8 @@ export abstract class VideoSend extends FormReactive implements OnInit {
videoPrivacies: VideoConstant<VideoPrivacy>[] = [] videoPrivacies: VideoConstant<VideoPrivacy>[] = []
videoCaptions: VideoCaptionEdit[] = [] videoCaptions: VideoCaptionEdit[] = []
firstStepPrivacyId = 0 firstStepPrivacyId: VideoPrivacy
firstStepChannelId = 0 firstStepChannelId: number
abstract firstStepDone: EventEmitter<string> abstract firstStepDone: EventEmitter<string>
abstract firstStepError: EventEmitter<void> abstract firstStepError: EventEmitter<void>
@ -24,11 +24,15 @@ export abstract class VideoSend extends FormReactive implements OnInit {
protected loadingBar: LoadingBarService protected loadingBar: LoadingBarService
protected notifier: Notifier protected notifier: Notifier
protected authService: AuthService protected authService: AuthService
protected serverService: ServerService protected serverService: ServerService
protected videoService: VideoService protected videoService: VideoService
protected videoCaptionService: VideoCaptionService protected videoCaptionService: VideoCaptionService
protected serverConfig: HTMLServerConfig protected serverConfig: HTMLServerConfig
protected highestPrivacy: VideoPrivacy
abstract canDeactivate (): CanComponentDeactivateResult abstract canDeactivate (): CanComponentDeactivateResult
ngOnInit () { ngOnInit () {
@ -49,6 +53,8 @@ export abstract class VideoSend extends FormReactive implements OnInit {
this.videoPrivacies = videoPrivacies this.videoPrivacies = videoPrivacies
this.firstStepPrivacyId = defaultPrivacyId 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, downloadEnabled: true,
channelId: this.firstStepChannelId, channelId: this.firstStepChannelId,
nsfw: this.serverConfig.instance.isNSFW, nsfw: this.serverConfig.instance.isNSFW,
privacy: VideoPrivacy.PRIVATE.toString(), privacy: this.highestPrivacy.toString(),
filename: file.name, filename: file.name,
previewfile: previewfile as any 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) { nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) {
return nsfwPolicy === 'do_not_list' return nsfwPolicy === 'do_not_list'
? 'false' ? 'false'