aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-19 10:43:53 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-10-24 14:48:24 +0200
commit9ab330b90decf4edf152ff8e1d2948c065766b2c (patch)
tree29d924f50f7307e8e828a57ecb9ea78623487ce0 /shared/core-utils
parent3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (diff)
downloadPeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.tar.gz
PeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.tar.zst
PeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.zip
Use private ACL for private videos in s3
Diffstat (limited to 'shared/core-utils')
-rw-r--r--shared/core-utils/common/env.ts20
-rw-r--r--shared/core-utils/videos/common.ts (renamed from shared/core-utils/videos/privacy.ts)15
-rw-r--r--shared/core-utils/videos/index.ts2
3 files changed, 29 insertions, 8 deletions
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 () {
14 return disabled 14 return disabled
15} 15}
16 16
17function areObjectStorageTestsDisabled () { 17function areMockObjectStorageTestsDisabled () {
18 const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true' 18 const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'
19 19
20 if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled') 20 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 () {
22 return disabled 22 return disabled
23} 23}
24 24
25function areScalewayObjectStorageTestsDisabled () {
26 if (areMockObjectStorageTestsDisabled()) return true
27
28 const enabled = process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID && process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY
29 if (!enabled) {
30 console.log(
31 'OBJECT_STORAGE_SCALEWAY_KEY_ID and/or OBJECT_STORAGE_SCALEWAY_ACCESS_KEY are not set, so scaleway object storage tests are disabled'
32 )
33
34 return true
35 }
36
37 return false
38}
39
25export { 40export {
26 parallelTests, 41 parallelTests,
27 isGithubCI, 42 isGithubCI,
28 areHttpImportTestsDisabled, 43 areHttpImportTestsDisabled,
29 areObjectStorageTestsDisabled 44 areMockObjectStorageTestsDisabled,
45 areScalewayObjectStorageTestsDisabled
30} 46}
diff --git a/shared/core-utils/videos/privacy.ts b/shared/core-utils/videos/common.ts
index f33487b49..2c6efdb7f 100644
--- a/shared/core-utils/videos/privacy.ts
+++ b/shared/core-utils/videos/common.ts
@@ -1,5 +1,6 @@
1import { VideoDetails } from '../../models/videos/video.model' 1import { VideoStreamingPlaylistType } from '@shared/models'
2import { VideoPrivacy } from '../../models/videos/video-privacy.enum' 2import { VideoPrivacy } from '../../models/videos/video-privacy.enum'
3import { VideoDetails } from '../../models/videos/video.model'
3 4
4function getAllPrivacies () { 5function getAllPrivacies () {
5 return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] 6 return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ]
@@ -8,14 +9,18 @@ function getAllPrivacies () {
8function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) { 9function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) {
9 const files = video.files 10 const files = video.files
10 11
11 if (video.streamingPlaylists[0]) { 12 const hls = getHLS(video)
12 return files.concat(video.streamingPlaylists[0].files) 13 if (hls) return files.concat(hls.files)
13 }
14 14
15 return files 15 return files
16} 16}
17 17
18function getHLS (video: Partial<Pick<VideoDetails, 'streamingPlaylists'>>) {
19 return video.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
20}
21
18export { 22export {
19 getAllPrivacies, 23 getAllPrivacies,
20 getAllFiles 24 getAllFiles,
25 getHLS
21} 26}
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 @@
1export * from './bitrate' 1export * from './bitrate'
2export * from './privacy' 2export * from './common'