X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=7fac8a4d6f68c59512e92a905fe66b97909b28c2;hb=9f79ade627f0044606a9fbbe16ca0154661d12b9;hp=e5c4c4e639866349294711ffafac289091bf2254;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index e5c4c4e63..7fac8a4d6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -10,13 +10,15 @@ import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' import { CronRepeatOptions, EveryRepeatOptions } from 'bull' import * as bytes from 'bytes' +import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' +import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' // Use a variable to reload the configuration if we need let config: IConfig = require('config') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 330 +const LAST_MIGRATION_VERSION = 345 // --------------------------------------------------------------------------- @@ -52,7 +54,9 @@ const SORTABLE_COLUMNS = { ACCOUNTS_BLOCKLIST: [ 'createdAt' ], SERVERS_BLOCKLIST: [ 'createdAt' ], - USER_NOTIFICATIONS: [ 'createdAt' ] + USER_NOTIFICATIONS: [ 'createdAt' ], + + VIDEO_PLAYLISTS: [ 'displayName', 'createdAt', 'updatedAt' ] } const OAUTH_LIFETIME = { @@ -192,7 +196,7 @@ const CONFIG = { AVATARS_DIR: buildPath(config.get('storage.avatars')), LOG_DIR: buildPath(config.get('storage.logs')), VIDEOS_DIR: buildPath(config.get('storage.videos')), - PLAYLISTS_DIR: buildPath(config.get('storage.playlists')), + STREAMING_PLAYLISTS_DIR: buildPath(config.get('storage.streaming_playlists')), REDUNDANCY_DIR: buildPath(config.get('storage.redundancy')), THUMBNAILS_DIR: buildPath(config.get('storage.thumbnails')), PREVIEWS_DIR: buildPath(config.get('storage.previews')), @@ -229,6 +233,11 @@ const CONFIG = { STRATEGIES: buildVideosRedundancy(config.get('redundancy.videos.strategies')) } }, + CSP: { + ENABLED: config.get('csp.enabled'), + REPORT_ONLY: config.get('csp.report_only'), + REPORT_URI: config.get('csp.report_uri') + }, ADMIN: { get EMAIL () { return config.get('admin.email') } }, @@ -288,6 +297,7 @@ const CONFIG = { get SHORT_DESCRIPTION () { return config.get('instance.short_description') }, get DESCRIPTION () { return config.get('instance.description') }, get TERMS () { return config.get('instance.terms') }, + get IS_NSFW () { return config.get('instance.is_nsfw') }, get DEFAULT_CLIENT_ROUTE () { return config.get('instance.default_client_route') }, get DEFAULT_NSFW_POLICY () { return config.get('instance.default_nsfw_policy') }, CUSTOMIZATIONS: { @@ -299,7 +309,6 @@ const CONFIG = { get SECURITYTXT_CONTACT () { return config.get('admin.email') } }, SERVICES: { - get 'CSP-LOGGER' () { return config.get('services.csp-logger') }, TWITTER: { get USERNAME () { return config.get('services.twitter.username') }, get WHITELISTED () { return config.get('services.twitter.whitelisted') } @@ -381,6 +390,17 @@ let CONSTRAINTS_FIELDS = { FILE_SIZE: { min: 10 }, URL: { min: 3, max: 2000 } // Length }, + VIDEO_PLAYLISTS: { + NAME: { min: 1, max: 120 }, // Length + DESCRIPTION: { min: 3, max: 1000 }, // Length + URL: { min: 3, max: 2000 }, // Length + IMAGE: { + EXTNAME: [ '.jpg', '.jpeg' ], + FILE_SIZE: { + max: 2 * 1024 * 1024 // 2MB + } + } + }, ACTORS: { PUBLIC_KEY: { min: 10, max: 5000 }, // Length PRIVATE_KEY: { min: 10, max: 5000 }, // Length @@ -497,6 +517,17 @@ const VIDEO_ABUSE_STATES = { [VideoAbuseState.ACCEPTED]: 'Accepted' } +const VIDEO_PLAYLIST_PRIVACIES = { + [VideoPlaylistPrivacy.PUBLIC]: 'Public', + [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', + [VideoPlaylistPrivacy.PRIVATE]: 'Private' +} + +const VIDEO_PLAYLIST_TYPES = { + [VideoPlaylistType.REGULAR]: 'Regular', + [VideoPlaylistType.WATCH_LATER]: 'Watch later' +} + const MIMETYPES = { VIDEO: { MIMETYPE_EXT: buildVideoMimetypeExt(), @@ -552,8 +583,9 @@ const ACTIVITY_PUB = { MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] }, MAX_RECURSION_COMMENTS: 100, - ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000, // 1 day - VIDEO_REFRESH_INTERVAL: 3600 * 24 * 1000 // 1 day + ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days + VIDEO_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days + VIDEO_PLAYLIST_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2 // 2 days } const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = { @@ -594,8 +626,8 @@ const STATIC_PATHS = { TORRENTS: '/static/torrents/', WEBSEED: '/static/webseed/', REDUNDANCY: '/static/redundancy/', - PLAYLISTS: { - HLS: '/static/playlists/hls' + STREAMING_PLAYLISTS: { + HLS: '/static/streaming-playlists/hls' }, AVATARS: '/static/avatars/', VIDEO_CAPTIONS: '/static/video-captions/' @@ -610,8 +642,8 @@ let STATIC_MAX_AGE = '2h' // Videos thumbnail size const THUMBNAILS_SIZE = { - width: 200, - height: 110 + width: 223, + height: 122 } const PREVIEWS_SIZE = { width: 560, @@ -639,7 +671,7 @@ const CACHE = { } } -const HLS_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.PLAYLISTS_DIR, 'hls') +const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') const MEMOIZE_TTL = { @@ -660,7 +692,7 @@ const CUSTOM_HTML_TAG_COMMENTS = { TITLE: '', DESCRIPTION: '', CUSTOM_CSS: '', - OPENGRAPH_AND_OEMBED: '' + META_TAGS: '' } // --------------------------------------------------------------------------- @@ -693,6 +725,7 @@ if (isTestInstance() === true) { ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds + ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB @@ -746,13 +779,14 @@ export { PRIVATE_RSA_KEY_SIZE, ROUTE_CACHE_LIFETIME, SORTABLE_COLUMNS, - HLS_PLAYLIST_DIRECTORY, + HLS_STREAMING_PLAYLIST_DIRECTORY, FEEDS, JOB_TTL, NSFW_POLICY_TYPES, STATIC_MAX_AGE, STATIC_PATHS, VIDEO_IMPORT_TIMEOUT, + VIDEO_PLAYLIST_TYPES, ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, THUMBNAILS_SIZE, @@ -781,6 +815,7 @@ export { VIDEO_IMPORT_STATES, VIDEO_VIEW_LIFETIME, CONTACT_FORM_LIFETIME, + VIDEO_PLAYLIST_PRIVACIES, buildLanguages }