diff options
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 129 |
1 files changed, 67 insertions, 62 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 032f63c8f..fb8ae7cd6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -4,7 +4,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub' | |||
4 | import { FollowState } from '../../shared/models/actors' | 4 | import { FollowState } from '../../shared/models/actors' |
5 | import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' | 5 | import { 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 |
7 | import { isTestInstance, sanitizeHost, sanitizeUrl, root, parseDurationToMs } from '../helpers/core-utils' | 7 | import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils' |
8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
9 | import { invert } from 'lodash' | 9 | import { invert } from 'lodash' |
10 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' | 10 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' |
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' | |||
14 | 14 | ||
15 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
16 | 16 | ||
17 | const LAST_MIGRATION_VERSION = 470 | 17 | const 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 | ||
79 | const OAUTH_LIFETIME = { | 81 | const OAUTH_LIFETIME = { |
@@ -117,45 +119,44 @@ const REMOTE_SCHEME = { | |||
117 | WS: 'wss' | 119 | WS: 'wss' |
118 | } | 120 | } |
119 | 121 | ||
120 | // TODO: remove 'video-file' | 122 | const JOB_ATTEMPTS: { [id in JobType]: number } = { |
121 | const 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 | } |
134 | const JOB_CONCURRENCY: { [id in (JobType | 'video-file')]: number } = { | 135 | const 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 | } |
147 | const JOB_TTL: { [id in (JobType | 'video-file')]: number } = { | 148 | const 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 | } |
160 | const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { | 161 | const 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 | ||
310 | const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { | 311 | const 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 | ||
361 | let VIDEO_LANGUAGES: { [id: string]: string } = {} | 364 | const VIDEO_LANGUAGES: { [id: string]: string } = {} |
362 | 365 | ||
363 | const VIDEO_PRIVACIES = { | 366 | const 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 | ||
370 | const VIDEO_STATES = { | 373 | const 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 | ||
376 | const VIDEO_IMPORT_STATES = { | 379 | const 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 | ||
382 | const VIDEO_ABUSE_STATES = { | 385 | const 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 | ||
388 | const VIDEO_PLAYLIST_PRIVACIES = { | 391 | const 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 | ||
394 | const VIDEO_PLAYLIST_TYPES = { | 397 | const 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 | ||
399 | const MIMETYPES = { | 402 | const MIMETYPES = { |
@@ -530,7 +533,7 @@ const LAZY_STATIC_PATHS = { | |||
530 | } | 533 | } |
531 | 534 | ||
532 | // Cache control | 535 | // Cache control |
533 | let STATIC_MAX_AGE = { | 536 | const STATIC_MAX_AGE = { |
534 | SERVER: '2h', | 537 | SERVER: '2h', |
535 | CLIENT: '30d' | 538 | CLIENT: '30d' |
536 | } | 539 | } |
@@ -538,11 +541,13 @@ let STATIC_MAX_AGE = { | |||
538 | // Videos thumbnail size | 541 | // Videos thumbnail size |
539 | const THUMBNAILS_SIZE = { | 542 | const THUMBNAILS_SIZE = { |
540 | width: 223, | 543 | width: 223, |
541 | height: 122 | 544 | height: 122, |
545 | minWidth: 150 | ||
542 | } | 546 | } |
543 | const PREVIEWS_SIZE = { | 547 | const PREVIEWS_SIZE = { |
544 | width: 850, | 548 | width: 850, |
545 | height: 480 | 549 | height: 480, |
550 | minWidth: 400 | ||
546 | } | 551 | } |
547 | const AVATARS_SIZE = { | 552 | const AVATARS_SIZE = { |
548 | width: 120, | 553 | width: 120, |
@@ -666,14 +671,14 @@ if (isTestInstance() === true) { | |||
666 | SCHEDULER_INTERVALS_MS.removeOldViews = 5000 | 671 | SCHEDULER_INTERVALS_MS.removeOldViews = 5000 |
667 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 672 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
668 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 | 673 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 |
669 | REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } | 674 | REPEAT_JOBS['videos-views'] = { every: 5000 } |
670 | 675 | ||
671 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 676 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
672 | 677 | ||
673 | VIDEO_VIEW_LIFETIME = 1000 // 1 second | 678 | VIDEO_VIEW_LIFETIME = 1000 // 1 second |
674 | CONTACT_FORM_LIFETIME = 1000 // 1 second | 679 | CONTACT_FORM_LIFETIME = 1000 // 1 second |
675 | 680 | ||
676 | JOB_ATTEMPTS[ 'email' ] = 1 | 681 | JOB_ATTEMPTS['email'] = 1 |
677 | 682 | ||
678 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | 683 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
679 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 | 684 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 |
@@ -833,42 +838,42 @@ function loadLanguages () { | |||
833 | function buildLanguages () { | 838 | function buildLanguages () { |
834 | const iso639 = require('iso-639-3') | 839 | const iso639 = require('iso-639-3') |
835 | 840 | ||
836 | const languages: { [ id: string ]: string } = {} | 841 | const languages: { [id: string]: string } = {} |
837 | 842 | ||
838 | const additionalLanguages = { | 843 | const additionalLanguages = { |
839 | 'sgn': true, // Sign languages (macro language) | 844 | sgn: true, // Sign languages (macro language) |
840 | 'ase': true, // American sign language | 845 | ase: true, // American sign language |
841 | 'sdl': true, // Arabian sign language | 846 | sdl: true, // Arabian sign language |
842 | 'bfi': true, // British sign language | 847 | bfi: true, // British sign language |
843 | 'bzs': true, // Brazilian sign language | 848 | bzs: true, // Brazilian sign language |
844 | 'csl': true, // Chinese sign language | 849 | csl: true, // Chinese sign language |
845 | 'cse': true, // Czech sign language | 850 | cse: true, // Czech sign language |
846 | 'dsl': true, // Danish sign language | 851 | dsl: true, // Danish sign language |
847 | 'fsl': true, // French sign language | 852 | fsl: true, // French sign language |
848 | 'gsg': true, // German sign language | 853 | gsg: true, // German sign language |
849 | 'pks': true, // Pakistan sign language | 854 | pks: true, // Pakistan sign language |
850 | 'jsl': true, // Japanese sign language | 855 | jsl: true, // Japanese sign language |
851 | 'sfs': true, // South African sign language | 856 | sfs: true, // South African sign language |
852 | 'swl': true, // Swedish sign language | 857 | swl: true, // Swedish sign language |
853 | 'rsl': true, // Russian sign language: true | 858 | rsl: true, // Russian sign language: true |
854 | 859 | ||
855 | 'epo': true, // Esperanto | 860 | epo: true, // Esperanto |
856 | 'tlh': true, // Klingon | 861 | tlh: true, // Klingon |
857 | 'jbo': true, // Lojban | 862 | jbo: true, // Lojban |
858 | 'avk': true // Kotava | 863 | avk: true // Kotava |
859 | } | 864 | } |
860 | 865 | ||
861 | // Only add ISO639-1 languages and some sign languages (ISO639-3) | 866 | // Only add ISO639-1 languages and some sign languages (ISO639-3) |
862 | iso639 | 867 | iso639 |
863 | .filter(l => { | 868 | .filter(l => { |
864 | return (l.iso6391 !== null && l.type === 'living') || | 869 | return (l.iso6391 !== null && l.type === 'living') || |
865 | additionalLanguages[ l.iso6393 ] === true | 870 | additionalLanguages[l.iso6393] === true |
866 | }) | 871 | }) |
867 | .forEach(l => languages[ l.iso6391 || l.iso6393 ] = l.name) | 872 | .forEach(l => { languages[l.iso6391 || l.iso6393] = l.name }) |
868 | 873 | ||
869 | // Override Occitan label | 874 | // Override Occitan label |
870 | languages[ 'oc' ] = 'Occitan' | 875 | languages['oc'] = 'Occitan' |
871 | languages[ 'el' ] = 'Greek' | 876 | languages['el'] = 'Greek' |
872 | 877 | ||
873 | return languages | 878 | return languages |
874 | } | 879 | } |