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.ts196
1 files changed, 141 insertions, 55 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 1a3b52015..e5c4c4e63 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -3,9 +3,9 @@ import { dirname, join } from 'path'
3import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models' 3import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models'
4import { ActivityPubActorType } from '../../shared/models/activitypub' 4import { ActivityPubActorType } from '../../shared/models/activitypub'
5import { FollowState } from '../../shared/models/actors' 5import { FollowState } from '../../shared/models/actors'
6import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos' 6import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos'
7// Do not use barrels, remain constants as independent as possible 7// Do not use barrels, remain constants as independent as possible
8import { buildPath, isTestInstance, parseDuration, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' 8import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
10import { invert } from 'lodash' 10import { invert } from 'lodash'
11import { CronRepeatOptions, EveryRepeatOptions } from 'bull' 11import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
@@ -16,7 +16,7 @@ let config: IConfig = require('config')
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
19const LAST_MIGRATION_VERSION = 275 19const LAST_MIGRATION_VERSION = 330
20 20
21// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
22 22
@@ -47,7 +47,12 @@ const SORTABLE_COLUMNS = {
47 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], 47 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ],
48 48
49 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ], 49 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ],
50 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ] 50 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
51
52 ACCOUNTS_BLOCKLIST: [ 'createdAt' ],
53 SERVERS_BLOCKLIST: [ 'createdAt' ],
54
55 USER_NOTIFICATIONS: [ 'createdAt' ]
51} 56}
52 57
53const OAUTH_LIFETIME = { 58const OAUTH_LIFETIME = {
@@ -58,6 +63,7 @@ const OAUTH_LIFETIME = {
58const ROUTE_CACHE_LIFETIME = { 63const ROUTE_CACHE_LIFETIME = {
59 FEEDS: '15 minutes', 64 FEEDS: '15 minutes',
60 ROBOTS: '2 hours', 65 ROBOTS: '2 hours',
66 SITEMAP: '1 day',
61 SECURITYTXT: '2 hours', 67 SECURITYTXT: '2 hours',
62 NODEINFO: '10 minutes', 68 NODEINFO: '10 minutes',
63 DNT_POLICY: '1 week', 69 DNT_POLICY: '1 week',
@@ -99,7 +105,8 @@ const JOB_ATTEMPTS: { [ id in JobType ]: number } = {
99 'video-file': 1, 105 'video-file': 1,
100 'video-import': 1, 106 'video-import': 1,
101 'email': 5, 107 'email': 5,
102 'videos-views': 1 108 'videos-views': 1,
109 'activitypub-refresher': 1
103} 110}
104const JOB_CONCURRENCY: { [ id in JobType ]: number } = { 111const JOB_CONCURRENCY: { [ id in JobType ]: number } = {
105 'activitypub-http-broadcast': 1, 112 'activitypub-http-broadcast': 1,
@@ -110,7 +117,8 @@ const JOB_CONCURRENCY: { [ id in JobType ]: number } = {
110 'video-file': 1, 117 'video-file': 1,
111 'video-import': 1, 118 'video-import': 1,
112 'email': 5, 119 'email': 5,
113 'videos-views': 1 120 'videos-views': 1,
121 'activitypub-refresher': 1
114} 122}
115const JOB_TTL: { [ id in JobType ]: number } = { 123const JOB_TTL: { [ id in JobType ]: number } = {
116 'activitypub-http-broadcast': 60000 * 10, // 10 minutes 124 'activitypub-http-broadcast': 60000 * 10, // 10 minutes
@@ -121,11 +129,12 @@ const JOB_TTL: { [ id in JobType ]: number } = {
121 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long 129 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long
122 'video-import': 1000 * 3600 * 2, // hours 130 'video-import': 1000 * 3600 * 2, // hours
123 'email': 60000 * 10, // 10 minutes 131 'email': 60000 * 10, // 10 minutes
124 'videos-views': undefined // Unlimited 132 'videos-views': undefined, // Unlimited
133 'activitypub-refresher': 60000 * 10 // 10 minutes
125} 134}
126const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { 135const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = {
127 'videos-views': { 136 'videos-views': {
128 cron: '1 * * * *' // At 1 minutes past the hour 137 cron: '1 * * * *' // At 1 minute past the hour
129 } 138 }
130} 139}
131 140
@@ -137,7 +146,7 @@ const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour
137 146
138// 1 hour 147// 1 hour
139let SCHEDULER_INTERVALS_MS = { 148let SCHEDULER_INTERVALS_MS = {
140 badActorFollow: 60000 * 60, // 1 hour 149 actorFollowScores: 60000 * 60, // 1 hour
141 removeOldJobs: 60000 * 60, // 1 hour 150 removeOldJobs: 60000 * 60, // 1 hour
142 updateVideos: 60000, // 1 minute 151 updateVideos: 60000, // 1 minute
143 youtubeDLUpdate: 60000 * 60 * 24 // 1 day 152 youtubeDLUpdate: 60000 * 60 * 24 // 1 day
@@ -179,9 +188,12 @@ const CONFIG = {
179 FROM_ADDRESS: config.get<string>('smtp.from_address') 188 FROM_ADDRESS: config.get<string>('smtp.from_address')
180 }, 189 },
181 STORAGE: { 190 STORAGE: {
191 TMP_DIR: buildPath(config.get<string>('storage.tmp')),
182 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), 192 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
183 LOG_DIR: buildPath(config.get<string>('storage.logs')), 193 LOG_DIR: buildPath(config.get<string>('storage.logs')),
184 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), 194 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
195 PLAYLISTS_DIR: buildPath(config.get<string>('storage.playlists')),
196 REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
185 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), 197 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
186 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), 198 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
187 CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), 199 CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')),
@@ -220,6 +232,9 @@ const CONFIG = {
220 ADMIN: { 232 ADMIN: {
221 get EMAIL () { return config.get<string>('admin.email') } 233 get EMAIL () { return config.get<string>('admin.email') }
222 }, 234 },
235 CONTACT_FORM: {
236 get ENABLED () { return config.get<boolean>('contact_form.enabled') }
237 },
223 SIGNUP: { 238 SIGNUP: {
224 get ENABLED () { return config.get<boolean>('signup.enabled') }, 239 get ENABLED () { return config.get<boolean>('signup.enabled') },
225 get LIMIT () { return config.get<number>('signup.limit') }, 240 get LIMIT () { return config.get<number>('signup.limit') },
@@ -232,11 +247,12 @@ const CONFIG = {
232 } 247 }
233 }, 248 },
234 USER: { 249 USER: {
235 get VIDEO_QUOTA () { return config.get<number>('user.video_quota') }, 250 get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
236 get VIDEO_QUOTA_DAILY () { return config.get<number>('user.video_quota_daily') } 251 get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
237 }, 252 },
238 TRANSCODING: { 253 TRANSCODING: {
239 get ENABLED () { return config.get<boolean>('transcoding.enabled') }, 254 get ENABLED () { return config.get<boolean>('transcoding.enabled') },
255 get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
240 get THREADS () { return config.get<number>('transcoding.threads') }, 256 get THREADS () { return config.get<number>('transcoding.threads') },
241 RESOLUTIONS: { 257 RESOLUTIONS: {
242 get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') }, 258 get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
@@ -244,6 +260,9 @@ const CONFIG = {
244 get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') }, 260 get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') },
245 get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') }, 261 get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') },
246 get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') } 262 get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') }
263 },
264 HLS: {
265 get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
247 } 266 }
248 }, 267 },
249 IMPORT: { 268 IMPORT: {
@@ -280,6 +299,7 @@ const CONFIG = {
280 get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') } 299 get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') }
281 }, 300 },
282 SERVICES: { 301 SERVICES: {
302 get 'CSP-LOGGER' () { return config.get<string>('services.csp-logger') },
283 TWITTER: { 303 TWITTER: {
284 get USERNAME () { return config.get<string>('services.twitter.username') }, 304 get USERNAME () { return config.get<string>('services.twitter.username') },
285 get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') } 305 get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }
@@ -289,27 +309,27 @@ const CONFIG = {
289 309
290// --------------------------------------------------------------------------- 310// ---------------------------------------------------------------------------
291 311
292const CONSTRAINTS_FIELDS = { 312let CONSTRAINTS_FIELDS = {
293 USERS: { 313 USERS: {
294 NAME: { min: 3, max: 120 }, // Length 314 NAME: { min: 1, max: 120 }, // Length
295 DESCRIPTION: { min: 3, max: 250 }, // Length 315 DESCRIPTION: { min: 3, max: 1000 }, // Length
296 USERNAME: { min: 3, max: 20 }, // Length 316 USERNAME: { min: 1, max: 50 }, // Length
297 PASSWORD: { min: 6, max: 255 }, // Length 317 PASSWORD: { min: 6, max: 255 }, // Length
298 VIDEO_QUOTA: { min: -1 }, 318 VIDEO_QUOTA: { min: -1 },
299 VIDEO_QUOTA_DAILY: { min: -1 }, 319 VIDEO_QUOTA_DAILY: { min: -1 },
300 BLOCKED_REASON: { min: 3, max: 250 } // Length 320 BLOCKED_REASON: { min: 3, max: 250 } // Length
301 }, 321 },
302 VIDEO_ABUSES: { 322 VIDEO_ABUSES: {
303 REASON: { min: 2, max: 300 }, // Length 323 REASON: { min: 2, max: 3000 }, // Length
304 MODERATION_COMMENT: { min: 2, max: 300 } // Length 324 MODERATION_COMMENT: { min: 2, max: 3000 } // Length
305 }, 325 },
306 VIDEO_BLACKLIST: { 326 VIDEO_BLACKLIST: {
307 REASON: { min: 2, max: 300 } // Length 327 REASON: { min: 2, max: 300 } // Length
308 }, 328 },
309 VIDEO_CHANNELS: { 329 VIDEO_CHANNELS: {
310 NAME: { min: 3, max: 120 }, // Length 330 NAME: { min: 1, max: 120 }, // Length
311 DESCRIPTION: { min: 3, max: 500 }, // Length 331 DESCRIPTION: { min: 3, max: 1000 }, // Length
312 SUPPORT: { min: 3, max: 500 }, // Length 332 SUPPORT: { min: 3, max: 1000 }, // Length
313 URL: { min: 3, max: 2000 } // Length 333 URL: { min: 3, max: 2000 } // Length
314 }, 334 },
315 VIDEO_CAPTIONS: { 335 VIDEO_CAPTIONS: {
@@ -333,19 +353,22 @@ const CONSTRAINTS_FIELDS = {
333 VIDEOS_REDUNDANCY: { 353 VIDEOS_REDUNDANCY: {
334 URL: { min: 3, max: 2000 } // Length 354 URL: { min: 3, max: 2000 } // Length
335 }, 355 },
356 VIDEO_RATES: {
357 URL: { min: 3, max: 2000 } // Length
358 },
336 VIDEOS: { 359 VIDEOS: {
337 NAME: { min: 3, max: 120 }, // Length 360 NAME: { min: 3, max: 120 }, // Length
338 LANGUAGE: { min: 1, max: 10 }, // Length 361 LANGUAGE: { min: 1, max: 10 }, // Length
339 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length 362 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
340 DESCRIPTION: { min: 3, max: 10000 }, // Length 363 DESCRIPTION: { min: 3, max: 10000 }, // Length
341 SUPPORT: { min: 3, max: 500 }, // Length 364 SUPPORT: { min: 3, max: 1000 }, // Length
342 IMAGE: { 365 IMAGE: {
343 EXTNAME: [ '.jpg', '.jpeg' ], 366 EXTNAME: [ '.jpg', '.jpeg' ],
344 FILE_SIZE: { 367 FILE_SIZE: {
345 max: 2 * 1024 * 1024 // 2MB 368 max: 2 * 1024 * 1024 // 2MB
346 } 369 }
347 }, 370 },
348 EXTNAME: [ '.mp4', '.ogv', '.webm' ], 371 EXTNAME: buildVideosExtname(),
349 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 372 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
350 DURATION: { min: 0 }, // Number 373 DURATION: { min: 0 }, // Number
351 TAGS: { min: 0, max: 5 }, // Number of total tags 374 TAGS: { min: 0, max: 5 }, // Number of total tags
@@ -378,6 +401,10 @@ const CONSTRAINTS_FIELDS = {
378 }, 401 },
379 VIDEO_SHARE: { 402 VIDEO_SHARE: {
380 URL: { min: 3, max: 2000 } // Length 403 URL: { min: 3, max: 2000 } // Length
404 },
405 CONTACT_FORM: {
406 FROM_NAME: { min: 1, max: 120 }, // Length
407 BODY: { min: 3, max: 5000 } // Length
381 } 408 }
382} 409}
383 410
@@ -393,7 +420,9 @@ const RATES_LIMIT = {
393} 420}
394 421
395let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour 422let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour
396const VIDEO_TRANSCODING_FPS = { 423let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
424
425const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
397 MIN: 10, 426 MIN: 10,
398 AVERAGE: 30, 427 AVERAGE: 30,
399 MAX: 60, 428 MAX: 60,
@@ -421,7 +450,7 @@ const VIDEO_CATEGORIES = {
421 8: 'People', 450 8: 'People',
422 9: 'Comedy', 451 9: 'Comedy',
423 10: 'Entertainment', 452 10: 'Entertainment',
424 11: 'News', 453 11: 'News & Politics',
425 12: 'How To', 454 12: 'How To',
426 13: 'Education', 455 13: 'Education',
427 14: 'Activism', 456 14: 'Activism',
@@ -468,27 +497,31 @@ const VIDEO_ABUSE_STATES = {
468 [VideoAbuseState.ACCEPTED]: 'Accepted' 497 [VideoAbuseState.ACCEPTED]: 'Accepted'
469} 498}
470 499
471const VIDEO_MIMETYPE_EXT = { 500const MIMETYPES = {
472 'video/webm': '.webm', 501 VIDEO: {
473 'video/ogg': '.ogv', 502 MIMETYPE_EXT: buildVideoMimetypeExt(),
474 'video/mp4': '.mp4' 503 EXT_MIMETYPE: null as { [ id: string ]: string }
475} 504 },
476const VIDEO_EXT_MIMETYPE = invert(VIDEO_MIMETYPE_EXT) 505 IMAGE: {
477 506 MIMETYPE_EXT: {
478const IMAGE_MIMETYPE_EXT = { 507 'image/png': '.png',
479 'image/png': '.png', 508 'image/jpg': '.jpg',
480 'image/jpg': '.jpg', 509 'image/jpeg': '.jpg'
481 'image/jpeg': '.jpg' 510 }
482} 511 },
483 512 VIDEO_CAPTIONS: {
484const VIDEO_CAPTIONS_MIMETYPE_EXT = { 513 MIMETYPE_EXT: {
485 'text/vtt': '.vtt', 514 'text/vtt': '.vtt',
486 'application/x-subrip': '.srt' 515 'application/x-subrip': '.srt'
487} 516 }
488 517 },
489const TORRENT_MIMETYPE_EXT = { 518 TORRENT: {
490 'application/x-bittorrent': '.torrent' 519 MIMETYPE_EXT: {
520 'application/x-bittorrent': '.torrent'
521 }
522 }
491} 523}
524MIMETYPES.VIDEO.EXT_MIMETYPE = invert(MIMETYPES.VIDEO.MIMETYPE_EXT)
492 525
493// --------------------------------------------------------------------------- 526// ---------------------------------------------------------------------------
494 527
@@ -514,7 +547,7 @@ const ACTIVITY_PUB = {
514 COLLECTION_ITEMS_PER_PAGE: 10, 547 COLLECTION_ITEMS_PER_PAGE: 10,
515 FETCH_PAGE_LIMIT: 100, 548 FETCH_PAGE_LIMIT: 100,
516 URL_MIME_TYPES: { 549 URL_MIME_TYPES: {
517 VIDEO: Object.keys(VIDEO_MIMETYPE_EXT), 550 VIDEO: Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT),
518 TORRENT: [ 'application/x-bittorrent' ], 551 TORRENT: [ 'application/x-bittorrent' ],
519 MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] 552 MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
520 }, 553 },
@@ -529,9 +562,15 @@ const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = {
529 APPLICATION: 'Application' 562 APPLICATION: 'Application'
530} 563}
531 564
565const HTTP_SIGNATURE = {
566 HEADER_NAME: 'signature',
567 ALGORITHM: 'rsa-sha256',
568 HEADERS_TO_SIGN: [ '(request-target)', 'host', 'date', 'digest' ]
569}
570
532// --------------------------------------------------------------------------- 571// ---------------------------------------------------------------------------
533 572
534const PRIVATE_RSA_KEY_SIZE = 2048 573let PRIVATE_RSA_KEY_SIZE = 2048
535 574
536// Password encryption 575// Password encryption
537const BCRYPT_SALT_SIZE = 10 576const BCRYPT_SALT_SIZE = 10
@@ -554,6 +593,10 @@ const STATIC_PATHS = {
554 THUMBNAILS: '/static/thumbnails/', 593 THUMBNAILS: '/static/thumbnails/',
555 TORRENTS: '/static/torrents/', 594 TORRENTS: '/static/torrents/',
556 WEBSEED: '/static/webseed/', 595 WEBSEED: '/static/webseed/',
596 REDUNDANCY: '/static/redundancy/',
597 PLAYLISTS: {
598 HLS: '/static/playlists/hls'
599 },
557 AVATARS: '/static/avatars/', 600 AVATARS: '/static/avatars/',
558 VIDEO_CAPTIONS: '/static/video-captions/' 601 VIDEO_CAPTIONS: '/static/video-captions/'
559} 602}
@@ -596,6 +639,9 @@ const CACHE = {
596 } 639 }
597} 640}
598 641
642const HLS_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.PLAYLISTS_DIR, 'hls')
643const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
644
599const MEMOIZE_TTL = { 645const MEMOIZE_TTL = {
600 OVERVIEWS_SAMPLE: 1000 * 3600 * 4 // 4 hours 646 OVERVIEWS_SAMPLE: 1000 * 3600 * 4 // 4 hours
601} 647}
@@ -635,6 +681,8 @@ const TRACKER_RATE_LIMITS = {
635 681
636// Special constants for a test instance 682// Special constants for a test instance
637if (isTestInstance() === true) { 683if (isTestInstance() === true) {
684 PRIVATE_RSA_KEY_SIZE = 1024
685
638 ACTOR_FOLLOW_SCORE.BASE = 20 686 ACTOR_FOLLOW_SCORE.BASE = 20
639 687
640 REMOTE_SCHEME.HTTP = 'http' 688 REMOTE_SCHEME.HTTP = 'http'
@@ -648,7 +696,7 @@ if (isTestInstance() === true) {
648 696
649 CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB 697 CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB
650 698
651 SCHEDULER_INTERVALS_MS.badActorFollow = 10000 699 SCHEDULER_INTERVALS_MS.actorFollowScores = 1000
652 SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 700 SCHEDULER_INTERVALS_MS.removeOldJobs = 10000
653 SCHEDULER_INTERVALS_MS.updateVideos = 5000 701 SCHEDULER_INTERVALS_MS.updateVideos = 5000
654 REPEAT_JOBS['videos-views'] = { every: 5000 } 702 REPEAT_JOBS['videos-views'] = { every: 5000 }
@@ -656,21 +704,24 @@ if (isTestInstance() === true) {
656 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 704 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
657 705
658 VIDEO_VIEW_LIFETIME = 1000 // 1 second 706 VIDEO_VIEW_LIFETIME = 1000 // 1 second
707 CONTACT_FORM_LIFETIME = 1000 // 1 second
659 708
660 JOB_ATTEMPTS['email'] = 1 709 JOB_ATTEMPTS['email'] = 1
661 710
662 CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 711 CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
663 MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 712 MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1
664 ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms' 713 ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms'
714
715 RATES_LIMIT.LOGIN.MAX = 20
665} 716}
666 717
667updateWebserverConfig() 718updateWebserverUrls()
668 719
669// --------------------------------------------------------------------------- 720// ---------------------------------------------------------------------------
670 721
671export { 722export {
672 API_VERSION, 723 API_VERSION,
673 VIDEO_CAPTIONS_MIMETYPE_EXT, 724 HLS_REDUNDANCY_DIRECTORY,
674 AVATARS_SIZE, 725 AVATARS_SIZE,
675 ACCEPT_HEADERS, 726 ACCEPT_HEADERS,
676 BCRYPT_SALT_SIZE, 727 BCRYPT_SALT_SIZE,
@@ -695,10 +746,10 @@ export {
695 PRIVATE_RSA_KEY_SIZE, 746 PRIVATE_RSA_KEY_SIZE,
696 ROUTE_CACHE_LIFETIME, 747 ROUTE_CACHE_LIFETIME,
697 SORTABLE_COLUMNS, 748 SORTABLE_COLUMNS,
749 HLS_PLAYLIST_DIRECTORY,
698 FEEDS, 750 FEEDS,
699 JOB_TTL, 751 JOB_TTL,
700 NSFW_POLICY_TYPES, 752 NSFW_POLICY_TYPES,
701 TORRENT_MIMETYPE_EXT,
702 STATIC_MAX_AGE, 753 STATIC_MAX_AGE,
703 STATIC_PATHS, 754 STATIC_PATHS,
704 VIDEO_IMPORT_TIMEOUT, 755 VIDEO_IMPORT_TIMEOUT,
@@ -711,7 +762,6 @@ export {
711 VIDEO_LICENCES, 762 VIDEO_LICENCES,
712 VIDEO_STATES, 763 VIDEO_STATES,
713 VIDEO_RATE_TYPES, 764 VIDEO_RATE_TYPES,
714 VIDEO_MIMETYPE_EXT,
715 VIDEO_TRANSCODING_FPS, 765 VIDEO_TRANSCODING_FPS,
716 FFMPEG_NICE, 766 FFMPEG_NICE,
717 VIDEO_ABUSE_STATES, 767 VIDEO_ABUSE_STATES,
@@ -719,17 +769,18 @@ export {
719 USER_PASSWORD_RESET_LIFETIME, 769 USER_PASSWORD_RESET_LIFETIME,
720 MEMOIZE_TTL, 770 MEMOIZE_TTL,
721 USER_EMAIL_VERIFY_LIFETIME, 771 USER_EMAIL_VERIFY_LIFETIME,
722 IMAGE_MIMETYPE_EXT,
723 OVERVIEWS, 772 OVERVIEWS,
724 SCHEDULER_INTERVALS_MS, 773 SCHEDULER_INTERVALS_MS,
725 REPEAT_JOBS, 774 REPEAT_JOBS,
726 STATIC_DOWNLOAD_PATHS, 775 STATIC_DOWNLOAD_PATHS,
727 RATES_LIMIT, 776 RATES_LIMIT,
728 VIDEO_EXT_MIMETYPE, 777 MIMETYPES,
729 CRAWL_REQUEST_CONCURRENCY, 778 CRAWL_REQUEST_CONCURRENCY,
730 JOB_COMPLETED_LIFETIME, 779 JOB_COMPLETED_LIFETIME,
780 HTTP_SIGNATURE,
731 VIDEO_IMPORT_STATES, 781 VIDEO_IMPORT_STATES,
732 VIDEO_VIEW_LIFETIME, 782 VIDEO_VIEW_LIFETIME,
783 CONTACT_FORM_LIFETIME,
733 buildLanguages 784 buildLanguages
734} 785}
735 786
@@ -746,16 +797,50 @@ function getLocalConfigFilePath () {
746 return join(dirname(configSources[ 0 ].name), filename + '.json') 797 return join(dirname(configSources[ 0 ].name), filename + '.json')
747} 798}
748 799
749function updateWebserverConfig () { 800function buildVideoMimetypeExt () {
801 const data = {
802 'video/webm': '.webm',
803 'video/ogg': '.ogv',
804 'video/mp4': '.mp4'
805 }
806
807 if (CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS) {
808 Object.assign(data, {
809 'video/quicktime': '.mov',
810 'video/x-msvideo': '.avi',
811 'video/x-flv': '.flv',
812 'video/x-matroska': '.mkv',
813 'application/octet-stream': '.mkv',
814 'video/avi': '.avi'
815 })
816 }
817
818 return data
819}
820
821function updateWebserverUrls () {
750 CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) 822 CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT)
751 CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) 823 CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
752} 824}
753 825
826function updateWebserverConfig () {
827 CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = buildVideosExtname()
828
829 MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt()
830 MIMETYPES.VIDEO.EXT_MIMETYPE = invert(MIMETYPES.VIDEO.MIMETYPE_EXT)
831}
832
833function buildVideosExtname () {
834 return CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS
835 ? [ '.mp4', '.ogv', '.webm', '.mkv', '.mov', '.avi', '.flv' ]
836 : [ '.mp4', '.ogv', '.webm' ]
837}
838
754function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { 839function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
755 if (!objs) return [] 840 if (!objs) return []
756 841
757 return objs.map(obj => { 842 return objs.map(obj => {
758 return Object.assign(obj, { 843 return Object.assign({}, obj, {
759 minLifetime: parseDuration(obj.min_lifetime), 844 minLifetime: parseDuration(obj.min_lifetime),
760 size: bytes.parse(obj.size), 845 size: bytes.parse(obj.size),
761 minViews: obj.min_views 846 minViews: obj.min_views
@@ -832,4 +917,5 @@ export function reloadConfig () {
832 config = require('config') 917 config = require('config')
833 918
834 updateWebserverConfig() 919 updateWebserverConfig()
920 updateWebserverUrls()
835} 921}