aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/constants.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r--server/initializers/constants.ts131
1 files changed, 68 insertions, 63 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 13e32b6d2..cb1c6f2ae 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -4,7 +4,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub'
4import { FollowState } from '../../shared/models/actors' 4import { FollowState } from '../../shared/models/actors'
5import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' 5import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos'
6// Do not use barrels, remain constants as independent as possible 6// Do not use barrels, remain constants as independent as possible
7import { isTestInstance, sanitizeHost, sanitizeUrl, root, parseDurationToMs } from '../helpers/core-utils' 7import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils'
8import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 8import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
9import { invert } from 'lodash' 9import { invert } from 'lodash'
10import { CronRepeatOptions, EveryRepeatOptions } from 'bull' 10import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
14 14
15// --------------------------------------------------------------------------- 15// ---------------------------------------------------------------------------
16 16
17const LAST_MIGRATION_VERSION = 470 17const LAST_MIGRATION_VERSION = 480
18 18
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
@@ -73,7 +73,9 @@ const SORTABLE_COLUMNS = {
73 73
74 PLUGINS: [ 'name', 'createdAt', 'updatedAt' ], 74 PLUGINS: [ 'name', 'createdAt', 'updatedAt' ],
75 75
76 AVAILABLE_PLUGINS: [ 'npmName', 'popularity' ] 76 AVAILABLE_PLUGINS: [ 'npmName', 'popularity' ],
77
78 VIDEO_REDUNDANCIES: [ 'name' ]
77} 79}
78 80
79const OAUTH_LIFETIME = { 81const OAUTH_LIFETIME = {
@@ -117,45 +119,44 @@ const REMOTE_SCHEME = {
117 WS: 'wss' 119 WS: 'wss'
118} 120}
119 121
120// TODO: remove 'video-file' 122const JOB_ATTEMPTS: { [id in JobType]: number } = {
121const JOB_ATTEMPTS: { [id in (JobType | 'video-file')]: number } = {
122 'activitypub-http-broadcast': 5, 123 'activitypub-http-broadcast': 5,
123 'activitypub-http-unicast': 5, 124 'activitypub-http-unicast': 5,
124 'activitypub-http-fetcher': 5, 125 'activitypub-http-fetcher': 5,
125 'activitypub-follow': 5, 126 'activitypub-follow': 5,
126 'video-file-import': 1, 127 'video-file-import': 1,
127 'video-transcoding': 1, 128 'video-transcoding': 1,
128 'video-file': 1,
129 'video-import': 1, 129 'video-import': 1,
130 'email': 5, 130 'email': 5,
131 'videos-views': 1, 131 'videos-views': 1,
132 'activitypub-refresher': 1 132 'activitypub-refresher': 1,
133 'video-redundancy': 1
133} 134}
134const JOB_CONCURRENCY: { [id in (JobType | 'video-file')]: number } = { 135const JOB_CONCURRENCY: { [id in JobType]: number } = {
135 'activitypub-http-broadcast': 1, 136 'activitypub-http-broadcast': 1,
136 'activitypub-http-unicast': 5, 137 'activitypub-http-unicast': 5,
137 'activitypub-http-fetcher': 1, 138 'activitypub-http-fetcher': 1,
138 'activitypub-follow': 1, 139 'activitypub-follow': 1,
139 'video-file-import': 1, 140 'video-file-import': 1,
140 'video-transcoding': 1, 141 'video-transcoding': 1,
141 'video-file': 1,
142 'video-import': 1, 142 'video-import': 1,
143 'email': 5, 143 'email': 5,
144 'videos-views': 1, 144 'videos-views': 1,
145 'activitypub-refresher': 1 145 'activitypub-refresher': 1,
146 'video-redundancy': 1
146} 147}
147const JOB_TTL: { [id in (JobType | 'video-file')]: number } = { 148const JOB_TTL: { [id in JobType]: number } = {
148 'activitypub-http-broadcast': 60000 * 10, // 10 minutes 149 'activitypub-http-broadcast': 60000 * 10, // 10 minutes
149 'activitypub-http-unicast': 60000 * 10, // 10 minutes 150 'activitypub-http-unicast': 60000 * 10, // 10 minutes
150 'activitypub-http-fetcher': 60000 * 10, // 10 minutes 151 'activitypub-http-fetcher': 60000 * 10, // 10 minutes
151 'activitypub-follow': 60000 * 10, // 10 minutes 152 'activitypub-follow': 60000 * 10, // 10 minutes
152 'video-file-import': 1000 * 3600, // 1 hour 153 'video-file-import': 1000 * 3600, // 1 hour
153 'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long 154 'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long
154 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long
155 'video-import': 1000 * 3600 * 2, // hours 155 'video-import': 1000 * 3600 * 2, // hours
156 'email': 60000 * 10, // 10 minutes 156 'email': 60000 * 10, // 10 minutes
157 'videos-views': undefined, // Unlimited 157 'videos-views': undefined, // Unlimited
158 'activitypub-refresher': 60000 * 10 // 10 minutes 158 'activitypub-refresher': 60000 * 10, // 10 minutes
159 'video-redundancy': 1000 * 3600 * 3 // 3 hours
159} 160}
160const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { 161const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = {
161 'videos-views': { 162 'videos-views': {
@@ -309,6 +310,8 @@ let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
309 310
310const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { 311const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
311 MIN: 10, 312 MIN: 10,
313 STANDARD: [ 24, 25, 30 ],
314 HD_STANDARD: [ 50, 60 ],
312 AVERAGE: 30, 315 AVERAGE: 30,
313 MAX: 60, 316 MAX: 60,
314 KEEP_ORIGIN_FPS_RESOLUTION_MIN: 720 // We keep the original FPS on high resolutions (720 minimum) 317 KEEP_ORIGIN_FPS_RESOLUTION_MIN: 720 // We keep the original FPS on high resolutions (720 minimum)
@@ -358,42 +361,42 @@ const VIDEO_LICENCES = {
358 7: 'Public Domain Dedication' 361 7: 'Public Domain Dedication'
359} 362}
360 363
361let VIDEO_LANGUAGES: { [id: string]: string } = {} 364const VIDEO_LANGUAGES: { [id: string]: string } = {}
362 365
363const VIDEO_PRIVACIES = { 366const VIDEO_PRIVACIES = {
364 [ VideoPrivacy.PUBLIC ]: 'Public', 367 [VideoPrivacy.PUBLIC]: 'Public',
365 [ VideoPrivacy.UNLISTED ]: 'Unlisted', 368 [VideoPrivacy.UNLISTED]: 'Unlisted',
366 [ VideoPrivacy.PRIVATE ]: 'Private', 369 [VideoPrivacy.PRIVATE]: 'Private',
367 [ VideoPrivacy.INTERNAL ]: 'Internal' 370 [VideoPrivacy.INTERNAL]: 'Internal'
368} 371}
369 372
370const VIDEO_STATES = { 373const VIDEO_STATES = {
371 [ VideoState.PUBLISHED ]: 'Published', 374 [VideoState.PUBLISHED]: 'Published',
372 [ VideoState.TO_TRANSCODE ]: 'To transcode', 375 [VideoState.TO_TRANSCODE]: 'To transcode',
373 [ VideoState.TO_IMPORT ]: 'To import' 376 [VideoState.TO_IMPORT]: 'To import'
374} 377}
375 378
376const VIDEO_IMPORT_STATES = { 379const VIDEO_IMPORT_STATES = {
377 [ VideoImportState.FAILED ]: 'Failed', 380 [VideoImportState.FAILED]: 'Failed',
378 [ VideoImportState.PENDING ]: 'Pending', 381 [VideoImportState.PENDING]: 'Pending',
379 [ VideoImportState.SUCCESS ]: 'Success' 382 [VideoImportState.SUCCESS]: 'Success'
380} 383}
381 384
382const VIDEO_ABUSE_STATES = { 385const VIDEO_ABUSE_STATES = {
383 [ VideoAbuseState.PENDING ]: 'Pending', 386 [VideoAbuseState.PENDING]: 'Pending',
384 [ VideoAbuseState.REJECTED ]: 'Rejected', 387 [VideoAbuseState.REJECTED]: 'Rejected',
385 [ VideoAbuseState.ACCEPTED ]: 'Accepted' 388 [VideoAbuseState.ACCEPTED]: 'Accepted'
386} 389}
387 390
388const VIDEO_PLAYLIST_PRIVACIES = { 391const VIDEO_PLAYLIST_PRIVACIES = {
389 [ VideoPlaylistPrivacy.PUBLIC ]: 'Public', 392 [VideoPlaylistPrivacy.PUBLIC]: 'Public',
390 [ VideoPlaylistPrivacy.UNLISTED ]: 'Unlisted', 393 [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted',
391 [ VideoPlaylistPrivacy.PRIVATE ]: 'Private' 394 [VideoPlaylistPrivacy.PRIVATE]: 'Private'
392} 395}
393 396
394const VIDEO_PLAYLIST_TYPES = { 397const VIDEO_PLAYLIST_TYPES = {
395 [ VideoPlaylistType.REGULAR ]: 'Regular', 398 [VideoPlaylistType.REGULAR]: 'Regular',
396 [ VideoPlaylistType.WATCH_LATER ]: 'Watch later' 399 [VideoPlaylistType.WATCH_LATER]: 'Watch later'
397} 400}
398 401
399const MIMETYPES = { 402const MIMETYPES = {
@@ -533,7 +536,7 @@ const LAZY_STATIC_PATHS = {
533} 536}
534 537
535// Cache control 538// Cache control
536let STATIC_MAX_AGE = { 539const STATIC_MAX_AGE = {
537 SERVER: '2h', 540 SERVER: '2h',
538 CLIENT: '30d' 541 CLIENT: '30d'
539} 542}
@@ -541,11 +544,13 @@ let STATIC_MAX_AGE = {
541// Videos thumbnail size 544// Videos thumbnail size
542const THUMBNAILS_SIZE = { 545const THUMBNAILS_SIZE = {
543 width: 223, 546 width: 223,
544 height: 122 547 height: 122,
548 minWidth: 150
545} 549}
546const PREVIEWS_SIZE = { 550const PREVIEWS_SIZE = {
547 width: 850, 551 width: 850,
548 height: 480 552 height: 480,
553 minWidth: 400
549} 554}
550const AVATARS_SIZE = { 555const AVATARS_SIZE = {
551 width: 120, 556 width: 120,
@@ -669,14 +674,14 @@ if (isTestInstance() === true) {
669 SCHEDULER_INTERVALS_MS.removeOldViews = 5000 674 SCHEDULER_INTERVALS_MS.removeOldViews = 5000
670 SCHEDULER_INTERVALS_MS.updateVideos = 5000 675 SCHEDULER_INTERVALS_MS.updateVideos = 5000
671 SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 676 SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000
672 REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } 677 REPEAT_JOBS['videos-views'] = { every: 5000 }
673 678
674 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 679 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
675 680
676 VIDEO_VIEW_LIFETIME = 1000 // 1 second 681 VIDEO_VIEW_LIFETIME = 1000 // 1 second
677 CONTACT_FORM_LIFETIME = 1000 // 1 second 682 CONTACT_FORM_LIFETIME = 1000 // 1 second
678 683
679 JOB_ATTEMPTS[ 'email' ] = 1 684 JOB_ATTEMPTS['email'] = 1
680 685
681 FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 686 FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
682 MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 687 MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1
@@ -837,42 +842,42 @@ function loadLanguages () {
837function buildLanguages () { 842function buildLanguages () {
838 const iso639 = require('iso-639-3') 843 const iso639 = require('iso-639-3')
839 844
840 const languages: { [ id: string ]: string } = {} 845 const languages: { [id: string]: string } = {}
841 846
842 const additionalLanguages = { 847 const additionalLanguages = {
843 'sgn': true, // Sign languages (macro language) 848 sgn: true, // Sign languages (macro language)
844 'ase': true, // American sign language 849 ase: true, // American sign language
845 'sdl': true, // Arabian sign language 850 sdl: true, // Arabian sign language
846 'bfi': true, // British sign language 851 bfi: true, // British sign language
847 'bzs': true, // Brazilian sign language 852 bzs: true, // Brazilian sign language
848 'csl': true, // Chinese sign language 853 csl: true, // Chinese sign language
849 'cse': true, // Czech sign language 854 cse: true, // Czech sign language
850 'dsl': true, // Danish sign language 855 dsl: true, // Danish sign language
851 'fsl': true, // French sign language 856 fsl: true, // French sign language
852 'gsg': true, // German sign language 857 gsg: true, // German sign language
853 'pks': true, // Pakistan sign language 858 pks: true, // Pakistan sign language
854 'jsl': true, // Japanese sign language 859 jsl: true, // Japanese sign language
855 'sfs': true, // South African sign language 860 sfs: true, // South African sign language
856 'swl': true, // Swedish sign language 861 swl: true, // Swedish sign language
857 'rsl': true, // Russian sign language: true 862 rsl: true, // Russian sign language: true
858 863
859 'epo': true, // Esperanto 864 epo: true, // Esperanto
860 'tlh': true, // Klingon 865 tlh: true, // Klingon
861 'jbo': true, // Lojban 866 jbo: true, // Lojban
862 'avk': true // Kotava 867 avk: true // Kotava
863 } 868 }
864 869
865 // Only add ISO639-1 languages and some sign languages (ISO639-3) 870 // Only add ISO639-1 languages and some sign languages (ISO639-3)
866 iso639 871 iso639
867 .filter(l => { 872 .filter(l => {
868 return (l.iso6391 !== null && l.type === 'living') || 873 return (l.iso6391 !== undefined && l.type === 'living') ||
869 additionalLanguages[ l.iso6393 ] === true 874 additionalLanguages[l.iso6393] === true
870 }) 875 })
871 .forEach(l => languages[ l.iso6391 || l.iso6393 ] = l.name) 876 .forEach(l => { languages[l.iso6391 || l.iso6393] = l.name })
872 877
873 // Override Occitan label 878 // Override Occitan label
874 languages[ 'oc' ] = 'Occitan' 879 languages['oc'] = 'Occitan'
875 languages[ 'el' ] = 'Greek' 880 languages['el'] = 'Greek'
876 881
877 return languages 882 return languages
878} 883}