From 9ab330b90decf4edf152ff8e1d2948c065766b2c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Oct 2022 10:43:53 +0200 Subject: Use private ACL for private videos in s3 --- shared/core-utils/common/env.ts | 20 ++++++++++++++++++-- shared/core-utils/videos/common.ts | 26 ++++++++++++++++++++++++++ shared/core-utils/videos/index.ts | 2 +- shared/core-utils/videos/privacy.ts | 21 --------------------- 4 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 shared/core-utils/videos/common.ts delete mode 100644 shared/core-utils/videos/privacy.ts (limited to 'shared/core-utils') diff --git a/shared/core-utils/common/env.ts b/shared/core-utils/common/env.ts index 38c96b152..973f895d4 100644 --- a/shared/core-utils/common/env.ts +++ b/shared/core-utils/common/env.ts @@ -14,7 +14,7 @@ function areHttpImportTestsDisabled () { return disabled } -function areObjectStorageTestsDisabled () { +function areMockObjectStorageTestsDisabled () { const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true' if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled') @@ -22,9 +22,25 @@ function areObjectStorageTestsDisabled () { return disabled } +function areScalewayObjectStorageTestsDisabled () { + if (areMockObjectStorageTestsDisabled()) return true + + const enabled = process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID && process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY + if (!enabled) { + console.log( + 'OBJECT_STORAGE_SCALEWAY_KEY_ID and/or OBJECT_STORAGE_SCALEWAY_ACCESS_KEY are not set, so scaleway object storage tests are disabled' + ) + + return true + } + + return false +} + export { parallelTests, isGithubCI, areHttpImportTestsDisabled, - areObjectStorageTestsDisabled + areMockObjectStorageTestsDisabled, + areScalewayObjectStorageTestsDisabled } diff --git a/shared/core-utils/videos/common.ts b/shared/core-utils/videos/common.ts new file mode 100644 index 000000000..2c6efdb7f --- /dev/null +++ b/shared/core-utils/videos/common.ts @@ -0,0 +1,26 @@ +import { VideoStreamingPlaylistType } from '@shared/models' +import { VideoPrivacy } from '../../models/videos/video-privacy.enum' +import { VideoDetails } from '../../models/videos/video.model' + +function getAllPrivacies () { + return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] +} + +function getAllFiles (video: Partial>) { + const files = video.files + + const hls = getHLS(video) + if (hls) return files.concat(hls.files) + + return files +} + +function getHLS (video: Partial>) { + return video.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS) +} + +export { + getAllPrivacies, + getAllFiles, + getHLS +} diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts index 620e3a716..2cf319395 100644 --- a/shared/core-utils/videos/index.ts +++ b/shared/core-utils/videos/index.ts @@ -1,2 +1,2 @@ export * from './bitrate' -export * from './privacy' +export * from './common' diff --git a/shared/core-utils/videos/privacy.ts b/shared/core-utils/videos/privacy.ts deleted file mode 100644 index f33487b49..000000000 --- a/shared/core-utils/videos/privacy.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { VideoDetails } from '../../models/videos/video.model' -import { VideoPrivacy } from '../../models/videos/video-privacy.enum' - -function getAllPrivacies () { - return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] -} - -function getAllFiles (video: Partial>) { - const files = video.files - - if (video.streamingPlaylists[0]) { - return files.concat(video.streamingPlaylists[0].files) - } - - return files -} - -export { - getAllPrivacies, - getAllFiles -} -- cgit v1.2.3