Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix sync privacy if private is removed by a plugin

Chocobozzz3889f441a7a4
diff --git a/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
index 510f0b66fe..d436f456b7 100644
--- a/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
@@ -103,7 +103,7 @@ export class VideoPublishComponent implements OnInit, CanComponentDeactivate {
this.user = this.auth.getUser()
this.serverConfig = this.serverService.getHTMLConfig()
- this.highestPrivacy = this.videoService.getHighestAvailablePrivacy(privacies)
+ this.highestPrivacy = this.videoService.getMostPrivatePrivacy(privacies)
if (this.route.snapshot.fragment) {
this.onNavChange(this.route.snapshot.fragment as VideoManageType)
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 cacbe16581..ee7addc2d7 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -599,7 +599,7 @@ export class VideoService {
return $localize`This video contains sensitive content: ${flags.join(' - ')}`
}
- getHighestAvailablePrivacy (serverPrivacies: VideoConstant<VideoPrivacyType>[]) {
+ getMostPrivatePrivacy (serverPrivacies: VideoConstant<VideoPrivacyType>[]) {
// We do not add a password as this requires additional configuration.
const order = [
VideoPrivacy.PRIVATE,
@@ -608,13 +608,17 @@ export class VideoService {
VideoPrivacy.PUBLIC
]
+ return this.getPrivacyFromOrder(serverPrivacies, order)
+ }
+
+ private getPrivacyFromOrder (serverPrivacies: VideoConstant<VideoPrivacyType>[], order: VideoPrivacyType[]) {
for (const privacy of order) {
if (serverPrivacies.find(p => p.id === privacy)) {
return privacy
}
}
- throw new Error('No highest privacy available')
+ throw new Error('No privacy available')
}
nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType): BooleanBothQuery {
diff --git a/server/core/lib/sync-channel.ts b/server/core/lib/sync-channel.ts
index 6b6ba7da60..71547aa4ef 100644
--- a/server/core/lib/sync-channel.ts
+++ b/server/core/lib/sync-channel.ts
@@ -1,4 +1,4 @@
-import { VideoChannelSyncState, VideoPrivacy } from '@peertube/peertube-models'
+import { VideoChannelSyncState } from '@peertube/peertube-models'
import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
import { YoutubeDLWrapper } from '@server/helpers/youtube-dl/index.js'
import { CONFIG } from '@server/initializers/config.js'
@@ -8,6 +8,7 @@ import { VideoImportModel } from '@server/models/video/video-import.js'
import { MChannelAccountDefault, MChannelSync } from '@server/types/models/index.js'
import { CreateJobArgument, JobQueue } from './job-queue/index.js'
import { ServerConfigManager } from './server-config-manager.js'
+import { getLeastPrivatePrivacy } from './video.js'
const lTags = loggerTagsFactory('channel-synchronization')
@@ -66,7 +67,7 @@ export async function synchronizeChannel (options: {
targetUrl,
channelSync,
importDataOverride: {
- privacy: VideoPrivacy.PUBLIC,
+ privacy: getLeastPrivatePrivacy(),
support: channel.support
}
})
diff --git a/server/core/lib/video.ts b/server/core/lib/video.ts
index 597766fc77..2fa9680e21 100644
--- a/server/core/lib/video.ts
+++ b/server/core/lib/video.ts
@@ -1,4 +1,5 @@
-import { MEMOIZE_LENGTH, MEMOIZE_TTL } from '@server/initializers/constants.js'
+import { VideoPrivacy } from '@peertube/peertube-models'
+import { MEMOIZE_LENGTH, MEMOIZE_TTL, VIDEO_PRIVACIES } from '@server/initializers/constants.js'
import { TagModel } from '@server/models/video/tag.js'
import { VideoModel } from '@server/models/video/video.js'
import { MVideoTag } from '@server/types/models/index.js'
@@ -38,3 +39,20 @@ export const getCachedVideoDuration = memoizee(getVideoDuration, {
max: MEMOIZE_LENGTH.VIDEO_DURATION,
maxAge: MEMOIZE_TTL.VIDEO_DURATION
})
+
+// ---------------------------------------------------------------------------
+
+export function getLeastPrivatePrivacy () {
+ const order = [
+ VideoPrivacy.PUBLIC,
+ VideoPrivacy.UNLISTED,
+ VideoPrivacy.INTERNAL,
+ VideoPrivacy.PRIVATE
+ ]
+
+ for (const privacy of order) {
+ if (VIDEO_PRIVACIES[privacy]) return privacy
+ }
+
+ throw new Error('No valid privacy found')
+}