import { RepeatOptions } from 'bullmq'
-import { randomBytes } from 'crypto'
+import { Encoding, randomBytes } from 'crypto'
import { invert } from 'lodash'
import { join } from 'path'
import { randomInt, root } from '@shared/core-utils'
import {
AbuseState,
JobType,
+ VideoChannelSyncState,
VideoImportState,
VideoPrivacy,
VideoRateType,
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 725
+const LAST_MIGRATION_VERSION = 745
// ---------------------------------------------------------------------------
JOBS: [ 'createdAt' ],
VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
VIDEO_IMPORTS: [ 'createdAt' ],
+ VIDEO_CHANNEL_SYNCS: [ 'externalChannelUrl', 'videoChannel', 'createdAt', 'lastSyncAt', 'state' ],
VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ],
VIDEO_COMMENTS: [ 'createdAt' ],
ACTIVITY_PUB: {
VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example
},
- STATS: '4 hours'
+ STATS: '4 hours',
+ WELL_KNOWN: '1 day'
}
// ---------------------------------------------------------------------------
'video-live-ending': 1,
'video-studio-edition': 1,
'manage-video-torrent': 1,
+ 'video-channel-import': 1,
+ 'after-video-channel-import': 1,
'move-to-object-storage': 3,
'notify': 1,
'federate-video': 1
'video-studio-edition': 1,
'manage-video-torrent': 1,
'move-to-object-storage': 1,
+ 'video-channel-import': 1,
+ 'after-video-channel-import': 1,
'notify': 5,
'federate-video': 3
}
'video-redundancy': 1000 * 3600 * 3, // 3 hours
'video-live-ending': 1000 * 60 * 10, // 10 minutes
'manage-video-torrent': 1000 * 3600 * 3, // 3 hours
+ 'move-to-object-storage': 1000 * 60 * 60 * 3, // 3 hours
+ 'video-channel-import': 1000 * 60 * 60 * 4, // 4 hours
+ 'after-video-channel-import': 60000 * 5, // 5 minutes
'notify': 60000 * 5, // 5 minutes
- 'federate-video': 60000 * 5, // 5 minutes
- 'move-to-object-storage': 1000 * 60 * 60 * 3 // 3 hours
+ 'federate-video': 60000 * 5 // 5 minutes
}
const REPEAT_JOBS: { [ id in JobType ]?: RepeatOptions } = {
'videos-views-stats': {
REMOVE_OLD_VIEWS: 60000 * 60 * 24, // 1 day
REMOVE_OLD_HISTORY: 60000 * 60 * 24, // 1 day
UPDATE_INBOX_STATS: 1000 * 60, // 1 minute
- REMOVE_DANGLING_RESUMABLE_UPLOADS: 60000 * 60 // 1 hour
+ REMOVE_DANGLING_RESUMABLE_UPLOADS: 60000 * 60, // 1 hour
+ CHANNEL_SYNC_CHECK_INTERVAL: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.CHECK_INTERVAL
}
// ---------------------------------------------------------------------------
NAME: { min: 1, max: 120 }, // Length
DESCRIPTION: { min: 3, max: 1000 }, // Length
SUPPORT: { min: 3, max: 1000 }, // Length
+ EXTERNAL_CHANNEL_URL: { min: 3, max: 2000 }, // Length
URL: { min: 3, max: 2000 } // Length
},
+ VIDEO_CHANNEL_SYNCS: {
+ EXTERNAL_CHANNEL_URL: { min: 3, max: 2000 } // Length
+ },
VIDEO_CAPTIONS: {
CAPTION_FILE: {
EXTNAME: [ '.vtt', '.srt' ],
[VideoImportState.PROCESSING]: 'Processing'
}
+const VIDEO_CHANNEL_SYNC_STATE: { [ id in VideoChannelSyncState ]: string } = {
+ [VideoChannelSyncState.FAILED]: 'Failed',
+ [VideoChannelSyncState.SYNCED]: 'Synchronized',
+ [VideoChannelSyncState.PROCESSING]: 'Processing',
+ [VideoChannelSyncState.WAITING_FIRST_RUN]: 'Waiting first run'
+}
+
const ABUSE_STATES: { [ id in AbuseState ]: string } = {
[AbuseState.PENDING]: 'Pending',
[AbuseState.REJECTED]: 'Rejected',
// Password encryption
const BCRYPT_SALT_SIZE = 10
+const ENCRYPTION = {
+ ALGORITHM: 'aes-256-cbc',
+ IV: 16,
+ SALT: 'peertube',
+ ENCODING: 'hex' as Encoding
+}
+
const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes
const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days
+const TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME = 60000 * 10 // 10 minutes
+
const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes
const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = {
// Express static paths (router)
const STATIC_PATHS = {
THUMBNAILS: '/static/thumbnails/',
+
WEBSEED: '/static/webseed/',
+ PRIVATE_WEBSEED: '/static/webseed/private/',
+
REDUNDANCY: '/static/redundancy/',
+
STREAMING_PLAYLISTS: {
- HLS: '/static/streaming-playlists/hls'
+ HLS: '/static/streaming-playlists/hls',
+ PRIVATE_HLS: '/static/streaming-playlists/hls/private/'
}
}
const STATIC_DOWNLOAD_PATHS = {
VIDEO_CAPTIONS: '/lazy-static/video-captions/',
TORRENTS: '/lazy-static/torrents/'
}
+const OBJECT_STORAGE_PROXY_PATHS = {
+ PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/',
+
+ STREAMING_PLAYLISTS: {
+ PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
+ }
+}
// Cache control
const STATIC_MAX_AGE = {
height: 480,
minWidth: 400
}
-const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[]} = {
+const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[] } = {
[ActorImageType.AVATAR]: [
{
width: 120,
},
ACTOR_IMAGE_STATIC: {
MAX_SIZE: 500
+ },
+ STATIC_VIDEO_FILES_RIGHTS_CHECK: {
+ MAX_SIZE: 5000,
+ TTL: parseDurationToMs('10 seconds')
+ },
+ VIDEO_TOKENS: {
+ MAX_SIZE: 100_000,
+ TTL: parseDurationToMs('8 hours')
}
}
-const RESUMABLE_UPLOAD_DIRECTORY = join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads')
-const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls')
-const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
+const DIRECTORIES = {
+ RESUMABLE_UPLOAD: join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads'),
+
+ HLS_STREAMING_PLAYLIST: {
+ PUBLIC: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls'),
+ PRIVATE: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls', 'private')
+ },
+
+ VIDEOS: {
+ PUBLIC: CONFIG.STORAGE.VIDEOS_DIR,
+ PRIVATE: join(CONFIG.STORAGE.VIDEOS_DIR, 'private')
+ },
+
+ HLS_REDUNDANCY: join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
+}
const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING_RESUMABLE_UPLOADS
}
const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)
+const OTP = {
+ HEADER_NAME: 'x-peertube-otp',
+ HEADER_REQUIRED_VALUE: 'required; app'
+}
const ASSETS_PATH = {
DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'),
export {
WEBSERVER,
API_VERSION,
+ ENCRYPTION,
VIDEO_LIVE,
PEERTUBE_VERSION,
LAZY_STATIC_PATHS,
+ OBJECT_STORAGE_PROXY_PATHS,
SEARCH_INDEX,
- RESUMABLE_UPLOAD_DIRECTORY,
+ DIRECTORIES,
RESUMABLE_UPLOAD_SESSION_LIFETIME,
- HLS_REDUNDANCY_DIRECTORY,
P2P_MEDIA_LOADER_PEER_VERSION,
ACTOR_IMAGES_SIZE,
ACCEPT_HEADERS,
FOLLOW_STATES,
DEFAULT_USER_THEME_NAME,
SERVER_ACTOR_NAME,
+ TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME,
PLUGIN_GLOBAL_CSS_FILE_NAME,
PLUGIN_GLOBAL_CSS_PATH,
PRIVATE_RSA_KEY_SIZE,
VIDEO_FILTERS,
ROUTE_CACHE_LIFETIME,
SORTABLE_COLUMNS,
- HLS_STREAMING_PLAYLIST_DIRECTORY,
JOB_TTL,
DEFAULT_THEME_NAME,
NSFW_POLICY_TYPES,
JOB_COMPLETED_LIFETIME,
HTTP_SIGNATURE,
VIDEO_IMPORT_STATES,
+ VIDEO_CHANNEL_SYNC_STATE,
VIEW_LIFETIME,
CONTACT_FORM_LIFETIME,
VIDEO_PLAYLIST_PRIVACIES,
PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME,
ASSETS_PATH,
FILES_CONTENT_HASH,
+ OTP,
loadLanguages,
buildLanguages,
generateContentHash