From 3092e9bbb05fe292fd13bc685b89069c3dda55d9 Mon Sep 17 00:00:00 2001 From: Levi Bard Date: Wed, 3 Jun 2020 09:42:07 +0200 Subject: Make federation of unlisted videos an instance-level server preference (#2802) * Add preference for federating unlisted videos * Connect unlisted video federation with new preference * Apply pull request feedback * Fix lint issues * Remove preference for federating unlisted videos from web admin interface --- server/helpers/video.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'server/helpers/video.ts') diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 6f76cbdfc..4bcc6d0b9 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -15,7 +15,8 @@ import { import { Response } from 'express' import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' import { JobQueue } from '@server/lib/job-queue' -import { VideoTranscodingPayload } from '@shared/models' +import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' +import { CONFIG } from "@server/initializers/config" type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' @@ -96,6 +97,19 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { : videoOrPlaylist } +function isPrivacyForFederation (privacy: VideoPrivacy) { + const castedPrivacy = parseInt(privacy + '', 10) + + return castedPrivacy === VideoPrivacy.PUBLIC || + (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED) +} + +function getPrivaciesForFederation () { + return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true) + ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ] + : [ { privacy: VideoPrivacy.PUBLIC } ] +} + export { VideoFetchType, VideoFetchByUrlType, @@ -103,5 +117,7 @@ export { getVideoWithAttributes, fetchVideoByUrl, addOptimizeOrMergeAudioJob, - extractVideo + extractVideo, + isPrivacyForFederation, + getPrivaciesForFederation } -- cgit v1.2.3