]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
store uploaded video filename (#4885)
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index e0f6f2bd2e94272dd63901993c67c92f206da5e4..0d7e7077d7b97b198830884fe7cf12e1ae6533f7 100644 (file)
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 690
+const LAST_MIGRATION_VERSION = 715
 
 // ---------------------------------------------------------------------------
 
@@ -58,7 +58,7 @@ const WEBSERVER = {
 
 // Sortable columns per schema
 const SORTABLE_COLUMNS = {
-  USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt', 'lastLoginDate', 'role' ],
+  ADMIN_USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt', 'lastLoginDate', 'role' ],
   USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ],
   ACCOUNTS: [ 'createdAt' ],
   JOBS: [ 'createdAt' ],
@@ -139,6 +139,7 @@ const REMOTE_SCHEME = {
 
 const JOB_ATTEMPTS: { [id in JobType]: number } = {
   'activitypub-http-broadcast': 1,
+  'activitypub-http-broadcast-parallel': 1,
   'activitypub-http-unicast': 1,
   'activitypub-http-fetcher': 2,
   'activitypub-follow': 5,
@@ -152,13 +153,14 @@ const JOB_ATTEMPTS: { [id in JobType]: number } = {
   'activitypub-refresher': 1,
   'video-redundancy': 1,
   'video-live-ending': 1,
-  'video-edition': 1,
+  'video-studio-edition': 1,
   'manage-video-torrent': 1,
   'move-to-object-storage': 3
 }
 // Excluded keys are jobs that can be configured by admins
 const JOB_CONCURRENCY: { [id in Exclude<JobType, 'video-transcoding' | 'video-import'>]: number } = {
   'activitypub-http-broadcast': 1,
+  'activitypub-http-broadcast-parallel': 30,
   'activitypub-http-unicast': 10,
   'activitypub-http-fetcher': 3,
   'activitypub-cleaner': 1,
@@ -170,20 +172,21 @@ const JOB_CONCURRENCY: { [id in Exclude<JobType, 'video-transcoding' | 'video-im
   'activitypub-refresher': 1,
   'video-redundancy': 1,
   'video-live-ending': 10,
-  'video-edition': 1,
+  'video-studio-edition': 1,
   'manage-video-torrent': 1,
   'move-to-object-storage': 1
 }
 const JOB_TTL: { [id in JobType]: number } = {
   'activitypub-http-broadcast': 60000 * 10, // 10 minutes
+  'activitypub-http-broadcast-parallel': 60000 * 10, // 10 minutes
   'activitypub-http-unicast': 60000 * 10, // 10 minutes
   'activitypub-http-fetcher': 1000 * 3600 * 10, // 10 hours
   'activitypub-follow': 60000 * 10, // 10 minutes
   'activitypub-cleaner': 1000 * 3600, // 1 hour
   'video-file-import': 1000 * 3600, // 1 hour
   'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long
-  'video-edition': 1000 * 3600 * 10, // 10 hours
-  'video-import': 1000 * 3600 * 2, // 2 hours
+  'video-studio-edition': 1000 * 3600 * 10, // 10 hours
+  'video-import': CONFIG.IMPORT.VIDEOS.TIMEOUT,
   'email': 60000 * 10, // 10 minutes
   'actor-keys': 60000 * 20, // 20 minutes
   'videos-views-stats': undefined, // Unlimited
@@ -210,7 +213,7 @@ const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch re
 
 const AP_CLEANER = {
   CONCURRENCY: 10, // How many requests in parallel we do in activitypub-cleaner job
-  UNAVAILABLE_TRESHOLD: 3, // How many attemps we do before removing an unavailable remote resource
+  UNAVAILABLE_TRESHOLD: 3, // How many attempts we do before removing an unavailable remote resource
   PERIOD: parseDurationToMs('1 week') // /!\ Has to be sync with REPEAT_JOBS
 }
 
@@ -228,6 +231,7 @@ const SCHEDULER_INTERVALS_MS = {
   REMOVE_OLD_JOBS: 60000 * 60, // 1 hour
   UPDATE_VIDEOS: 60000, // 1 minute
   YOUTUBE_DL_UPDATE: 60000 * 60 * 24, // 1 day
+  GEO_IP_UPDATE: 60000 * 60 * 24, // 1 day
   VIDEO_VIEWS_BUFFER_UPDATE: CONFIG.VIEWS.VIDEOS.LOCAL_BUFFER_UPDATE_INTERVAL,
   CHECK_PLUGINS: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL,
   CHECK_PEERTUBE_VERSION: 60000 * 60 * 24, // 1 day
@@ -358,7 +362,7 @@ const CONSTRAINTS_FIELDS = {
   COMMONS: {
     URL: { min: 5, max: 2000 } // Length
   },
-  VIDEO_EDITOR: {
+  VIDEO_STUDIO: {
     TASKS: { min: 1, max: 10 }, // Number of tasks
     CUT_TIME: { min: 0 } // Value
   }
@@ -366,9 +370,12 @@ const CONSTRAINTS_FIELDS = {
 
 const VIEW_LIFETIME = {
   VIEW: CONFIG.VIEWS.VIDEOS.IP_VIEW_EXPIRATION,
-  VIEWER: 60000 * 5 // 5 minutes
+  VIEWER_COUNTER: 60000 * 2, // 2 minutes
+  VIEWER_STATS: 60000 * 60 // 1 hour
 }
 
+const MAX_LOCAL_VIEWER_WATCH_SECTIONS = 100
+
 let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
 
 const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
@@ -480,17 +487,25 @@ const MIMETYPES = {
     MIMETYPE_EXT: {
       'audio/mpeg': '.mp3',
       'audio/mp3': '.mp3',
+
       'application/ogg': '.ogg',
       'audio/ogg': '.ogg',
+
       'audio/x-ms-wma': '.wma',
       'audio/wav': '.wav',
       'audio/x-wav': '.wav',
+
       'audio/x-flac': '.flac',
       'audio/flac': '.flac',
+
+      'audio/vnd.dlna.adts': '.aac',
       'audio/aac': '.aac',
+
       'audio/m4a': '.m4a',
       'audio/mp4': '.m4a',
       'audio/x-m4a': '.m4a',
+
+      'audio/vnd.dolby.dd-raw': '.ac3',
       'audio/ac3': '.ac3'
     },
     EXT_MIMETYPE: null as { [ id: string ]: string }
@@ -578,10 +593,6 @@ const HTTP_SIGNATURE = {
   HEADER_NAME: 'signature',
   ALGORITHM: 'rsa-sha256',
   HEADERS_TO_SIGN: [ '(request-target)', 'host', 'date', 'digest' ],
-  REQUIRED_HEADERS: {
-    ALL: [ '(request-target)', 'host', 'date' ],
-    POST: [ '(request-target)', 'host', 'date', 'digest' ]
-  },
   CLOCK_SKEW_SECONDS: 1800
 }
 
@@ -723,12 +734,14 @@ const VIDEO_LIVE = {
 const MEMOIZE_TTL = {
   OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours
   INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours
+  VIDEO_DURATION: 1000 * 10, // 10 seconds
   LIVE_ABLE_TO_UPLOAD: 1000 * 60, // 1 minute
   LIVE_CHECK_SOCKET_HEALTH: 1000 * 60 // 1 minute
 }
 
 const MEMOIZE_LENGTH = {
-  INFO_HASH_EXISTS: 200
+  INFO_HASH_EXISTS: 200,
+  VIDEO_DURATION: 200
 }
 
 const QUEUE_CONCURRENCY = {
@@ -758,12 +771,6 @@ const CUSTOM_HTML_TAG_COMMENTS = {
   SERVER_CONFIG: '<!-- server config -->'
 }
 
-// ---------------------------------------------------------------------------
-
-const FEEDS = {
-  COUNT: 20
-}
-
 const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000
 const LOG_FILENAME = 'peertube.log'
 const AUDIT_LOG_FILENAME = 'peertube-audit.log'
@@ -800,8 +807,14 @@ const SEARCH_INDEX = {
 
 // ---------------------------------------------------------------------------
 
+const STATS_TIMESERIE = {
+  MAX_DAYS: 365 * 10 // Around 10 years
+}
+
+// ---------------------------------------------------------------------------
+
 // Special constants for a test instance
-if (isTestInstance() === true) {
+if (isTestInstance() === true && process.env.PRODUCTION_CONSTANTS !== 'true') {
   PRIVATE_RSA_KEY_SIZE = 1024
 
   ACTOR_FOLLOW_SCORE.BASE = 20
@@ -835,7 +848,8 @@ if (isTestInstance() === true) {
 
   REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
 
-  VIEW_LIFETIME.VIEWER = 1000 * 5 // 5 second
+  VIEW_LIFETIME.VIEWER_COUNTER = 1000 * 5 // 5 second
+  VIEW_LIFETIME.VIEWER_STATS = 1000 * 5 // 5 second
   CONTACT_FORM_LIFETIME = 1000 // 1 second
 
   JOB_ATTEMPTS['email'] = 1
@@ -907,6 +921,7 @@ export {
   LAST_MIGRATION_VERSION,
   OAUTH_LIFETIME,
   CUSTOM_HTML_TAG_COMMENTS,
+  STATS_TIMESERIE,
   BROADCAST_CONCURRENCY,
   AUDIT_LOG_FILENAME,
   PAGINATION,
@@ -923,7 +938,6 @@ export {
   ROUTE_CACHE_LIFETIME,
   SORTABLE_COLUMNS,
   HLS_STREAMING_PLAYLIST_DIRECTORY,
-  FEEDS,
   JOB_TTL,
   DEFAULT_THEME_NAME,
   NSFW_POLICY_TYPES,
@@ -949,6 +963,7 @@ export {
   ABUSE_STATES,
   LRU_CACHE,
   REQUEST_TIMEOUTS,
+  MAX_LOCAL_VIEWER_WATCH_SECTIONS,
   USER_PASSWORD_RESET_LIFETIME,
   USER_PASSWORD_CREATE_LIFETIME,
   MEMOIZE_TTL,
@@ -1020,6 +1035,8 @@ function buildVideoMimetypeExt () {
         // The standard video format used by many Sony and Panasonic HD camcorders.
         // It is also used for storing high definition video on Blu-ray discs.
         'video/mp2t': '.mts',
+        'video/vnd.dlna.mpeg-tts': '.mts',
+
         'video/m2ts': '.m2ts',
 
         // Old formats reliant on MPEG-1/MPEG-2
@@ -1051,8 +1068,11 @@ function updateWebserverUrls () {
   WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME
   WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
 
-  WEBSERVER.RTMP_URL = 'rtmp://' + CONFIG.LIVE.RTMP.HOSTNAME + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
-  WEBSERVER.RTMPS_URL = 'rtmps://' + CONFIG.LIVE.RTMPS.HOSTNAME + ':' + CONFIG.LIVE.RTMPS.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
+  const rtmpHostname = CONFIG.LIVE.RTMP.PUBLIC_HOSTNAME || CONFIG.WEBSERVER.HOSTNAME
+  const rtmpsHostname = CONFIG.LIVE.RTMPS.PUBLIC_HOSTNAME || CONFIG.WEBSERVER.HOSTNAME
+
+  WEBSERVER.RTMP_URL = 'rtmp://' + rtmpHostname + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
+  WEBSERVER.RTMPS_URL = 'rtmps://' + rtmpsHostname + ':' + CONFIG.LIVE.RTMPS.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
 }
 
 function updateWebserverConfig () {