-import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
-import { randomBytes } from 'crypto'
+import { RepeatOptions } from 'bullmq'
+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 = 720
+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'
}
// ---------------------------------------------------------------------------
const FOLLOW_STATES: { [ id: string ]: FollowState } = {
PENDING: 'pending',
- ACCEPTED: 'accepted'
+ ACCEPTED: 'accepted',
+ REJECTED: 'rejected'
}
const REMOTE_SCHEME = {
'video-live-ending': 1,
'video-studio-edition': 1,
'manage-video-torrent': 1,
- 'move-to-object-storage': 3
+ 'video-channel-import': 1,
+ 'after-video-channel-import': 1,
+ 'move-to-object-storage': 3,
+ 'notify': 1,
+ 'federate-video': 1
}
// Excluded keys are jobs that can be configured by admins
const JOB_CONCURRENCY: { [id in Exclude<JobType, 'video-transcoding' | 'video-import'>]: number } = {
'video-live-ending': 10,
'video-studio-edition': 1,
'manage-video-torrent': 1,
- 'move-to-object-storage': 1
+ 'move-to-object-storage': 1,
+ 'video-channel-import': 1,
+ 'after-video-channel-import': 1,
+ 'notify': 5,
+ 'federate-video': 3
}
const JOB_TTL: { [id in JobType]: number } = {
'activitypub-http-broadcast': 60000 * 10, // 10 minutes
'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
+ '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
}
-const REPEAT_JOBS: { [ id in JobType ]?: EveryRepeatOptions | CronRepeatOptions } = {
+const REPEAT_JOBS: { [ id in JobType ]?: RepeatOptions } = {
'videos-views-stats': {
cron: randomInt(1, 20) + ' * * * *' // Between 1-20 minutes past the hour
},
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' ],
},
LOGS: {
CLIENT_MESSAGE: { min: 1, max: 1000 }, // Length
- CLIENT_STACK_TRACE: { min: 1, max: 5000 }, // Length
+ CLIENT_STACK_TRACE: { min: 1, max: 15000 }, // Length
CLIENT_META: { min: 1, max: 5000 }, // Length
CLIENT_USER_AGENT: { min: 1, max: 200 } // Length
}
[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 } = {
PROCESS_IMAGE: {
CONCURRENCY: 1,
MAX_THREADS: 5
+ },
+ SEQUENTIAL_HTTP_BROADCAST: {
+ CONCURRENCY: 1,
+ MAX_THREADS: 1
+ },
+ PARALLEL_HTTP_BROADCAST: {
+ CONCURRENCY: JOB_CONCURRENCY['activitypub-http-broadcast-parallel'],
+ MAX_THREADS: 1
}
}
}
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,
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,
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