diff options
author | Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> | 2020-06-03 09:42:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 09:42:07 +0200 |
commit | 3092e9bbb05fe292fd13bc685b89069c3dda55d9 (patch) | |
tree | 42b9d04dd7749e835e09cb912677aaad21333a5d /server/helpers | |
parent | 78646451c9896db3c2239270cd7e100305749f41 (diff) | |
download | PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.gz PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.zst PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.zip |
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
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/video.ts | 20 |
1 files changed, 18 insertions, 2 deletions
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 { | |||
15 | import { Response } from 'express' | 15 | import { Response } from 'express' |
16 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | 16 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' |
17 | import { JobQueue } from '@server/lib/job-queue' | 17 | import { JobQueue } from '@server/lib/job-queue' |
18 | import { VideoTranscodingPayload } from '@shared/models' | 18 | import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' |
19 | import { CONFIG } from "@server/initializers/config" | ||
19 | 20 | ||
20 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 21 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
21 | 22 | ||
@@ -96,6 +97,19 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | |||
96 | : videoOrPlaylist | 97 | : videoOrPlaylist |
97 | } | 98 | } |
98 | 99 | ||
100 | function isPrivacyForFederation (privacy: VideoPrivacy) { | ||
101 | const castedPrivacy = parseInt(privacy + '', 10) | ||
102 | |||
103 | return castedPrivacy === VideoPrivacy.PUBLIC || | ||
104 | (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED) | ||
105 | } | ||
106 | |||
107 | function getPrivaciesForFederation () { | ||
108 | return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true) | ||
109 | ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ] | ||
110 | : [ { privacy: VideoPrivacy.PUBLIC } ] | ||
111 | } | ||
112 | |||
99 | export { | 113 | export { |
100 | VideoFetchType, | 114 | VideoFetchType, |
101 | VideoFetchByUrlType, | 115 | VideoFetchByUrlType, |
@@ -103,5 +117,7 @@ export { | |||
103 | getVideoWithAttributes, | 117 | getVideoWithAttributes, |
104 | fetchVideoByUrl, | 118 | fetchVideoByUrl, |
105 | addOptimizeOrMergeAudioJob, | 119 | addOptimizeOrMergeAudioJob, |
106 | extractVideo | 120 | extractVideo, |
121 | isPrivacyForFederation, | ||
122 | getPrivaciesForFederation | ||
107 | } | 123 | } |