]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
Merge branch 'release/4.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index c61c01d62e8e3b59ac3d1a17c3dcb5fa0b6bf859..f66e6b65d5ffaf120e57a2b2315631817cdbec0b 100644 (file)
@@ -2,7 +2,7 @@ import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
 import { randomBytes } from 'crypto'
 import { invert } from 'lodash'
 import { join } from 'path'
-import { randomInt } from '../../shared/core-utils/common/miscs'
+import { randomInt, root } from '@shared/core-utils'
 import {
   AbuseState,
   JobType,
@@ -19,12 +19,12 @@ import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
 import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
 import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
 // Do not use barrels, remain constants as independent as possible
-import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
+import { isTestInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
 import { CONFIG, registerConfigChangedHandler } from './config'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 670
+const LAST_MIGRATION_VERSION = 675
 
 // ---------------------------------------------------------------------------
 
@@ -200,8 +200,14 @@ const JOB_PRIORITY = {
 }
 
 const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job
-const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job
 const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...)
+
+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
+  PERIOD: parseDurationToMs('1 week') // /!\ Has to be sync with REPEAT_JOBS
+}
+
 const REQUEST_TIMEOUTS = {
   DEFAULT: 7000, // 7 seconds
   FILE: 30000, // 30 seconds
@@ -209,7 +215,7 @@ const REQUEST_TIMEOUTS = {
 }
 
 const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
-const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour
+const VIDEO_IMPORT_TIMEOUT = Math.floor(JOB_TTL['video-import'] * 0.9)
 
 const SCHEDULER_INTERVALS_MS = {
   ACTOR_FOLLOW_SCORES: 60000 * 60, // 1 hour
@@ -259,7 +265,7 @@ const CONSTRAINTS_FIELDS = {
     CAPTION_FILE: {
       EXTNAME: [ '.vtt', '.srt' ],
       FILE_SIZE: {
-        max: 4 * 1024 * 1024 // 4MB
+        max: 20 * 1024 * 1024 // 20MB
       }
     }
   },
@@ -427,14 +433,17 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = {
   [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream',
   [VideoState.LIVE_ENDED]: 'Livestream ended',
   [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage',
-  [VideoState.TRANSCODING_FAILED]: 'Transcoding failed'
+  [VideoState.TRANSCODING_FAILED]: 'Transcoding failed',
+  [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'External storage move failed'
 }
 
 const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = {
   [VideoImportState.FAILED]: 'Failed',
   [VideoImportState.PENDING]: 'Pending',
   [VideoImportState.SUCCESS]: 'Success',
-  [VideoImportState.REJECTED]: 'Rejected'
+  [VideoImportState.REJECTED]: 'Rejected',
+  [VideoImportState.CANCELLED]: 'Cancelled',
+  [VideoImportState.PROCESSING]: 'Processing'
 }
 
 const ABUSE_STATES: { [ id in AbuseState ]: string } = {
@@ -795,8 +804,11 @@ if (isTestInstance() === true) {
   SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000
   SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000
   SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000
+
   REPEAT_JOBS['videos-views-stats'] = { every: 5000 }
+
   REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 }
+  AP_CLEANER.PERIOD = 5000
 
   REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
 
@@ -857,7 +869,7 @@ export {
   REDUNDANCY,
   JOB_CONCURRENCY,
   JOB_ATTEMPTS,
-  AP_CLEANER_CONCURRENCY,
+  AP_CLEANER,
   LAST_MIGRATION_VERSION,
   OAUTH_LIFETIME,
   CUSTOM_HTML_TAG_COMMENTS,
@@ -1075,7 +1087,9 @@ function buildLanguages () {
     epo: true, // Esperanto
     tlh: true, // Klingon
     jbo: true, // Lojban
-    avk: true // Kotava
+    avk: true, // Kotava
+
+    zxx: true // No linguistic content (ISO-639-2)
   }
 
   // Only add ISO639-1 languages and some sign languages (ISO639-3)
@@ -1090,6 +1104,10 @@ function buildLanguages () {
   languages['oc'] = 'Occitan'
   languages['el'] = 'Greek'
 
+  // Chinese languages
+  languages['zh-Hans'] = 'Simplified Chinese'
+  languages['zh-Hant'] = 'Traditional Chinese'
+
   return languages
 }