X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=server%2Fhelpers%2Fvideo.ts;h=89c85accb26fb461f138dfd036433c62a9b3699e;hb=26d6bf6533023326fa017812cf31bbe20c752d36;hp=6f76cbdfc755a23f14f882600b86a7366e93747d;hpb=8dc8a34ee8428e7657414115d1c137592efa174d;p=oweals%2Fpeertube.git diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 6f76cbdfc..89c85accb 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -11,11 +11,12 @@ import { MVideoImmutable, MVideoThumbnail, MVideoWithRights -} from '@server/typings/models' +} from '@server/types/models' 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 }