aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/video.ts
diff options
context:
space:
mode:
authorLevi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>2020-06-03 09:42:07 +0200
committerGitHub <noreply@github.com>2020-06-03 09:42:07 +0200
commit3092e9bbb05fe292fd13bc685b89069c3dda55d9 (patch)
tree42b9d04dd7749e835e09cb912677aaad21333a5d /server/helpers/video.ts
parent78646451c9896db3c2239270cd7e100305749f41 (diff)
downloadPeerTube-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/video.ts')
-rw-r--r--server/helpers/video.ts20
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 {
15import { Response } from 'express' 15import { Response } from 'express'
16import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' 16import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants'
17import { JobQueue } from '@server/lib/job-queue' 17import { JobQueue } from '@server/lib/job-queue'
18import { VideoTranscodingPayload } from '@shared/models' 18import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models'
19import { CONFIG } from "@server/initializers/config"
19 20
20type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' 21type 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
100function 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
107function getPrivaciesForFederation () {
108 return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true)
109 ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ]
110 : [ { privacy: VideoPrivacy.PUBLIC } ]
111}
112
99export { 113export {
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}