diff options
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 137 |
1 files changed, 73 insertions, 64 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 13e32b6d2..3da06402c 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 = { |
@@ -419,7 +422,8 @@ const MIMETYPES = { | |||
419 | 'image/png': '.png', | 422 | 'image/png': '.png', |
420 | 'image/jpg': '.jpg', | 423 | 'image/jpg': '.jpg', |
421 | 'image/jpeg': '.jpg' | 424 | 'image/jpeg': '.jpg' |
422 | } | 425 | }, |
426 | EXT_MIMETYPE: null as { [ id: string ]: string } | ||
423 | }, | 427 | }, |
424 | VIDEO_CAPTIONS: { | 428 | VIDEO_CAPTIONS: { |
425 | MIMETYPE_EXT: { | 429 | MIMETYPE_EXT: { |
@@ -435,6 +439,7 @@ const MIMETYPES = { | |||
435 | } | 439 | } |
436 | } | 440 | } |
437 | MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT) | 441 | MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT) |
442 | MIMETYPES.IMAGE.EXT_MIMETYPE = invert(MIMETYPES.IMAGE.MIMETYPE_EXT) | ||
438 | 443 | ||
439 | // --------------------------------------------------------------------------- | 444 | // --------------------------------------------------------------------------- |
440 | 445 | ||
@@ -497,6 +502,7 @@ let PRIVATE_RSA_KEY_SIZE = 2048 | |||
497 | const BCRYPT_SALT_SIZE = 10 | 502 | const BCRYPT_SALT_SIZE = 10 |
498 | 503 | ||
499 | const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes | 504 | const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes |
505 | const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days | ||
500 | 506 | ||
501 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes | 507 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes |
502 | 508 | ||
@@ -533,7 +539,7 @@ const LAZY_STATIC_PATHS = { | |||
533 | } | 539 | } |
534 | 540 | ||
535 | // Cache control | 541 | // Cache control |
536 | let STATIC_MAX_AGE = { | 542 | const STATIC_MAX_AGE = { |
537 | SERVER: '2h', | 543 | SERVER: '2h', |
538 | CLIENT: '30d' | 544 | CLIENT: '30d' |
539 | } | 545 | } |
@@ -541,11 +547,13 @@ let STATIC_MAX_AGE = { | |||
541 | // Videos thumbnail size | 547 | // Videos thumbnail size |
542 | const THUMBNAILS_SIZE = { | 548 | const THUMBNAILS_SIZE = { |
543 | width: 223, | 549 | width: 223, |
544 | height: 122 | 550 | height: 122, |
551 | minWidth: 150 | ||
545 | } | 552 | } |
546 | const PREVIEWS_SIZE = { | 553 | const PREVIEWS_SIZE = { |
547 | width: 850, | 554 | width: 850, |
548 | height: 480 | 555 | height: 480, |
556 | minWidth: 400 | ||
549 | } | 557 | } |
550 | const AVATARS_SIZE = { | 558 | const AVATARS_SIZE = { |
551 | width: 120, | 559 | width: 120, |
@@ -669,14 +677,14 @@ if (isTestInstance() === true) { | |||
669 | SCHEDULER_INTERVALS_MS.removeOldViews = 5000 | 677 | SCHEDULER_INTERVALS_MS.removeOldViews = 5000 |
670 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 678 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
671 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 | 679 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 |
672 | REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } | 680 | REPEAT_JOBS['videos-views'] = { every: 5000 } |
673 | 681 | ||
674 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 682 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
675 | 683 | ||
676 | VIDEO_VIEW_LIFETIME = 1000 // 1 second | 684 | VIDEO_VIEW_LIFETIME = 1000 // 1 second |
677 | CONTACT_FORM_LIFETIME = 1000 // 1 second | 685 | CONTACT_FORM_LIFETIME = 1000 // 1 second |
678 | 686 | ||
679 | JOB_ATTEMPTS[ 'email' ] = 1 | 687 | JOB_ATTEMPTS['email'] = 1 |
680 | 688 | ||
681 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | 689 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
682 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 | 690 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 |
@@ -757,6 +765,7 @@ export { | |||
757 | LRU_CACHE, | 765 | LRU_CACHE, |
758 | JOB_REQUEST_TIMEOUT, | 766 | JOB_REQUEST_TIMEOUT, |
759 | USER_PASSWORD_RESET_LIFETIME, | 767 | USER_PASSWORD_RESET_LIFETIME, |
768 | USER_PASSWORD_CREATE_LIFETIME, | ||
760 | MEMOIZE_TTL, | 769 | MEMOIZE_TTL, |
761 | USER_EMAIL_VERIFY_LIFETIME, | 770 | USER_EMAIL_VERIFY_LIFETIME, |
762 | OVERVIEWS, | 771 | OVERVIEWS, |
@@ -837,42 +846,42 @@ function loadLanguages () { | |||
837 | function buildLanguages () { | 846 | function buildLanguages () { |
838 | const iso639 = require('iso-639-3') | 847 | const iso639 = require('iso-639-3') |
839 | 848 | ||
840 | const languages: { [ id: string ]: string } = {} | 849 | const languages: { [id: string]: string } = {} |
841 | 850 | ||
842 | const additionalLanguages = { | 851 | const additionalLanguages = { |
843 | 'sgn': true, // Sign languages (macro language) | 852 | sgn: true, // Sign languages (macro language) |
844 | 'ase': true, // American sign language | 853 | ase: true, // American sign language |
845 | 'sdl': true, // Arabian sign language | 854 | sdl: true, // Arabian sign language |
846 | 'bfi': true, // British sign language | 855 | bfi: true, // British sign language |
847 | 'bzs': true, // Brazilian sign language | 856 | bzs: true, // Brazilian sign language |
848 | 'csl': true, // Chinese sign language | 857 | csl: true, // Chinese sign language |
849 | 'cse': true, // Czech sign language | 858 | cse: true, // Czech sign language |
850 | 'dsl': true, // Danish sign language | 859 | dsl: true, // Danish sign language |
851 | 'fsl': true, // French sign language | 860 | fsl: true, // French sign language |
852 | 'gsg': true, // German sign language | 861 | gsg: true, // German sign language |
853 | 'pks': true, // Pakistan sign language | 862 | pks: true, // Pakistan sign language |
854 | 'jsl': true, // Japanese sign language | 863 | jsl: true, // Japanese sign language |
855 | 'sfs': true, // South African sign language | 864 | sfs: true, // South African sign language |
856 | 'swl': true, // Swedish sign language | 865 | swl: true, // Swedish sign language |
857 | 'rsl': true, // Russian sign language: true | 866 | rsl: true, // Russian sign language: true |
858 | 867 | ||
859 | 'epo': true, // Esperanto | 868 | epo: true, // Esperanto |
860 | 'tlh': true, // Klingon | 869 | tlh: true, // Klingon |
861 | 'jbo': true, // Lojban | 870 | jbo: true, // Lojban |
862 | 'avk': true // Kotava | 871 | avk: true // Kotava |
863 | } | 872 | } |
864 | 873 | ||
865 | // Only add ISO639-1 languages and some sign languages (ISO639-3) | 874 | // Only add ISO639-1 languages and some sign languages (ISO639-3) |
866 | iso639 | 875 | iso639 |
867 | .filter(l => { | 876 | .filter(l => { |
868 | return (l.iso6391 !== null && l.type === 'living') || | 877 | return (l.iso6391 !== undefined && l.type === 'living') || |
869 | additionalLanguages[ l.iso6393 ] === true | 878 | additionalLanguages[l.iso6393] === true |
870 | }) | 879 | }) |
871 | .forEach(l => languages[ l.iso6391 || l.iso6393 ] = l.name) | 880 | .forEach(l => { languages[l.iso6391 || l.iso6393] = l.name }) |
872 | 881 | ||
873 | // Override Occitan label | 882 | // Override Occitan label |
874 | languages[ 'oc' ] = 'Occitan' | 883 | languages['oc'] = 'Occitan' |
875 | languages[ 'el' ] = 'Greek' | 884 | languages['el'] = 'Greek' |
876 | 885 | ||
877 | return languages | 886 | return languages |
878 | } | 887 | } |