]>
Commit | Line | Data |
---|---|---|
6dd9de95 | 1 | import { join } from 'path' |
536598cf | 2 | import { JobType, VideoRateType, VideoResolution, VideoState } from '../../shared/models' |
50d6de9c | 3 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
225a89c2 | 4 | import { FollowState } from '../../shared/models/actors' |
edb4ffc7 | 5 | import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' |
e02643f3 | 6 | // Do not use barrels, remain constants as independent as possible |
a1587156 | 7 | import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils' |
0883b324 | 8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
28be8916 | 9 | import { invert } from 'lodash' |
6b616860 | 10 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' |
418d092a | 11 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' |
df0b219d | 12 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' |
6dd9de95 | 13 | import { CONFIG, registerConfigChangedHandler } from './config' |
ee9e7b61 | 14 | |
9f6bae3a C |
15 | // --------------------------------------------------------------------------- |
16 | ||
8319d6ae | 17 | const LAST_MIGRATION_VERSION = 485 |
5804c0db C |
18 | |
19 | // --------------------------------------------------------------------------- | |
20 | ||
f0f5567b | 21 | const API_VERSION = 'v1' |
9fa6ca16 | 22 | const PEERTUBE_VERSION = require(join(root(), 'package.json')).version |
9f10b292 | 23 | |
1194e8b4 | 24 | const PAGINATION = { |
e0b56b74 C |
25 | GLOBAL: { |
26 | COUNT: { | |
27 | DEFAULT: 15, | |
28 | MAX: 100 | |
29 | } | |
30 | }, | |
31 | OUTBOX: { | |
32 | COUNT: { | |
33 | MAX: 50 | |
34 | } | |
1194e8b4 C |
35 | } |
36 | } | |
9f6bae3a | 37 | |
6dd9de95 C |
38 | const WEBSERVER = { |
39 | URL: '', | |
40 | HOST: '', | |
41 | SCHEME: '', | |
42 | WS: '', | |
43 | HOSTNAME: '', | |
44 | PORT: 0 | |
45 | } | |
46 | ||
9f6bae3a C |
47 | // Sortable columns per schema |
48 | const SORTABLE_COLUMNS = { | |
aa3796bd | 49 | USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt' ], |
06a05d5f | 50 | USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ], |
265ba139 | 51 | ACCOUNTS: [ 'createdAt' ], |
94a5ff8a | 52 | JOBS: [ 'createdAt' ], |
26b7305a | 53 | VIDEO_ABUSES: [ 'id', 'createdAt', 'state' ], |
72c7248b | 54 | VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ], |
ed31c059 | 55 | VIDEO_IMPORTS: [ 'createdAt' ], |
c1125bca | 56 | VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ], |
c100a614 | 57 | VIDEO_RATES: [ 'createdAt' ], |
7a7724e6 | 58 | BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], |
cb5ce4cb C |
59 | FOLLOWERS: [ 'createdAt', 'state', 'score' ], |
60 | FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ], | |
57c36b27 | 61 | |
2fd59d7d | 62 | VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending' ], |
9a629c6e | 63 | |
2fd59d7d | 64 | VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'match' ], |
7ad9b984 C |
65 | VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ], |
66 | ||
67 | ACCOUNTS_BLOCKLIST: [ 'createdAt' ], | |
cef534ed C |
68 | SERVERS_BLOCKLIST: [ 'createdAt' ], |
69 | ||
418d092a C |
70 | USER_NOTIFICATIONS: [ 'createdAt' ], |
71 | ||
ad91e700 C |
72 | VIDEO_PLAYLISTS: [ 'displayName', 'createdAt', 'updatedAt' ], |
73 | ||
6702a1b2 C |
74 | PLUGINS: [ 'name', 'createdAt', 'updatedAt' ], |
75 | ||
b764380a C |
76 | AVAILABLE_PLUGINS: [ 'npmName', 'popularity' ], |
77 | ||
78 | VIDEO_REDUNDANCIES: [ 'name' ] | |
9f6bae3a | 79 | } |
9f10b292 | 80 | |
2f372a86 | 81 | const OAUTH_LIFETIME = { |
ff193d5e | 82 | ACCESS_TOKEN: 3600 * 24, // 1 day, for upload |
2f372a86 C |
83 | REFRESH_TOKEN: 1209600 // 2 weeks |
84 | } | |
85 | ||
fd4484f1 | 86 | const ROUTE_CACHE_LIFETIME = { |
3f6d68d9 RK |
87 | FEEDS: '15 minutes', |
88 | ROBOTS: '2 hours', | |
2feebf3e | 89 | SITEMAP: '1 day', |
5447516b | 90 | SECURITYTXT: '2 hours', |
3f6d68d9 | 91 | NODEINFO: '10 minutes', |
aad0ec24 | 92 | DNT_POLICY: '1 week', |
fd4484f1 | 93 | ACTIVITY_PUB: { |
3f6d68d9 | 94 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example |
4b5384f6 C |
95 | }, |
96 | STATS: '4 hours' | |
fd4484f1 C |
97 | } |
98 | ||
9f6bae3a | 99 | // --------------------------------------------------------------------------- |
26d7d31b | 100 | |
60650c77 C |
101 | // Number of points we add/remove after a successful/bad request |
102 | const ACTOR_FOLLOW_SCORE = { | |
225a89c2 C |
103 | PENALTY: -10, |
104 | BONUS: 10, | |
60650c77 C |
105 | BASE: 1000, |
106 | MAX: 10000 | |
225a89c2 C |
107 | } |
108 | ||
109 | const FOLLOW_STATES: { [ id: string ]: FollowState } = { | |
110 | PENDING: 'pending', | |
111 | ACCEPTED: 'accepted' | |
112 | } | |
113 | ||
114 | const REMOTE_SCHEME = { | |
115 | HTTP: 'https', | |
116 | WS: 'wss' | |
117 | } | |
118 | ||
b764380a | 119 | const JOB_ATTEMPTS: { [id in JobType]: number } = { |
94a5ff8a C |
120 | 'activitypub-http-broadcast': 5, |
121 | 'activitypub-http-unicast': 5, | |
122 | 'activitypub-http-fetcher': 5, | |
5350fd8e | 123 | 'activitypub-follow': 5, |
0138af92 | 124 | 'video-file-import': 1, |
a0327eed | 125 | 'video-transcoding': 1, |
fbad87b0 | 126 | 'video-import': 1, |
6b616860 | 127 | 'email': 5, |
04b8c3fb | 128 | 'videos-views': 1, |
b764380a C |
129 | 'activitypub-refresher': 1, |
130 | 'video-redundancy': 1 | |
225a89c2 | 131 | } |
b764380a | 132 | const JOB_CONCURRENCY: { [id in JobType]: number } = { |
94a5ff8a C |
133 | 'activitypub-http-broadcast': 1, |
134 | 'activitypub-http-unicast': 5, | |
135 | 'activitypub-http-fetcher': 1, | |
ab4d4db4 | 136 | 'activitypub-follow': 1, |
0138af92 | 137 | 'video-file-import': 1, |
a0327eed | 138 | 'video-transcoding': 1, |
fbad87b0 | 139 | 'video-import': 1, |
6b616860 | 140 | 'email': 5, |
04b8c3fb | 141 | 'videos-views': 1, |
b764380a C |
142 | 'activitypub-refresher': 1, |
143 | 'video-redundancy': 1 | |
225a89c2 | 144 | } |
b764380a | 145 | const JOB_TTL: { [id in JobType]: number } = { |
2b86fe72 C |
146 | 'activitypub-http-broadcast': 60000 * 10, // 10 minutes |
147 | 'activitypub-http-unicast': 60000 * 10, // 10 minutes | |
d694b193 | 148 | 'activitypub-http-fetcher': 1000 * 3600 * 10, // 10 hours |
2b86fe72 C |
149 | 'activitypub-follow': 60000 * 10, // 10 minutes |
150 | 'video-file-import': 1000 * 3600, // 1 hour | |
a0327eed | 151 | 'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long |
d694b193 | 152 | 'video-import': 1000 * 3600 * 2, // 2 hours |
6b616860 | 153 | 'email': 60000 * 10, // 10 minutes |
04b8c3fb | 154 | 'videos-views': undefined, // Unlimited |
b764380a C |
155 | 'activitypub-refresher': 60000 * 10, // 10 minutes |
156 | 'video-redundancy': 1000 * 3600 * 3 // 3 hours | |
2b86fe72 | 157 | } |
6b616860 C |
158 | const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { |
159 | 'videos-views': { | |
04b8c3fb | 160 | cron: '1 * * * *' // At 1 minute past the hour |
6b616860 C |
161 | } |
162 | } | |
163 | ||
71e3dfda | 164 | const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job |
240085d0 | 165 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) |
71e3dfda | 166 | const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds |
71e3dfda | 167 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days |
cf9166cf | 168 | const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour |
225a89c2 | 169 | |
8f0bc73d | 170 | const SCHEDULER_INTERVALS_MS = { |
2f5c6b2f | 171 | actorFollowScores: 60000 * 60, // 1 hour |
bbe0f064 | 172 | removeOldJobs: 60000 * 60, // 1 hour |
ce32426b | 173 | updateVideos: 60000, // 1 minute |
8f0bc73d | 174 | youtubeDLUpdate: 60000 * 60 * 24, // 1 day |
d133f385 | 175 | checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, |
6f1b4fa4 | 176 | autoFollowIndexInstances: 60000 * 60 * 24, // 1 day |
cda03765 | 177 | removeOldViews: 60000 * 60 * 24, // 1 day |
8f0bc73d | 178 | removeOldHistory: 60000 * 60 * 24 // 1 day |
2baea0c7 | 179 | } |
60650c77 | 180 | |
6f1b4fa4 C |
181 | const INSTANCES_INDEX = { |
182 | HOSTS_PATH: '/api/v1/instances/hosts' | |
183 | } | |
184 | ||
225a89c2 C |
185 | // --------------------------------------------------------------------------- |
186 | ||
503c6f44 | 187 | const CONSTRAINTS_FIELDS = { |
e4c55619 | 188 | USERS: { |
9f7a1953 | 189 | NAME: { min: 1, max: 120 }, // Length |
d23e6a1c | 190 | DESCRIPTION: { min: 3, max: 1000 }, // Length |
d0ce42c1 | 191 | USERNAME: { min: 1, max: 50 }, // Length |
b0f9f39e | 192 | PASSWORD: { min: 6, max: 255 }, // Length |
eacb25c4 | 193 | VIDEO_QUOTA: { min: -1 }, |
bee0abff | 194 | VIDEO_QUOTA_DAILY: { min: -1 }, |
3caf77d3 | 195 | VIDEO_LANGUAGES: { max: 500 }, // Array length |
eacb25c4 | 196 | BLOCKED_REASON: { min: 3, max: 250 } // Length |
e4c55619 | 197 | }, |
55fa55a9 | 198 | VIDEO_ABUSES: { |
1506307f C |
199 | REASON: { min: 2, max: 3000 }, // Length |
200 | MODERATION_COMMENT: { min: 2, max: 3000 } // Length | |
55fa55a9 | 201 | }, |
26b7305a C |
202 | VIDEO_BLACKLIST: { |
203 | REASON: { min: 2, max: 300 } // Length | |
204 | }, | |
72c7248b | 205 | VIDEO_CHANNELS: { |
9f7a1953 | 206 | NAME: { min: 1, max: 120 }, // Length |
d23e6a1c BY |
207 | DESCRIPTION: { min: 3, max: 1000 }, // Length |
208 | SUPPORT: { min: 3, max: 1000 }, // Length | |
e34c85e5 | 209 | URL: { min: 3, max: 2000 } // Length |
72c7248b | 210 | }, |
40e87e9e C |
211 | VIDEO_CAPTIONS: { |
212 | CAPTION_FILE: { | |
f4001cf4 | 213 | EXTNAME: [ '.vtt', '.srt' ], |
40e87e9e C |
214 | FILE_SIZE: { |
215 | max: 2 * 1024 * 1024 // 2MB | |
216 | } | |
217 | } | |
218 | }, | |
fbad87b0 | 219 | VIDEO_IMPORTS: { |
ce33919c C |
220 | URL: { min: 3, max: 2000 }, // Length |
221 | TORRENT_NAME: { min: 3, max: 255 }, // Length | |
990b6a0b C |
222 | TORRENT_FILE: { |
223 | EXTNAME: [ '.torrent' ], | |
224 | FILE_SIZE: { | |
225 | max: 1024 * 200 // 200 KB | |
226 | } | |
227 | } | |
fbad87b0 | 228 | }, |
c48e82b5 C |
229 | VIDEOS_REDUNDANCY: { |
230 | URL: { min: 3, max: 2000 } // Length | |
231 | }, | |
5c6d985f C |
232 | VIDEO_RATES: { |
233 | URL: { min: 3, max: 2000 } // Length | |
234 | }, | |
e4c55619 | 235 | VIDEOS: { |
a265f7f3 | 236 | NAME: { min: 3, max: 120 }, // Length |
9d3ef9fe | 237 | LANGUAGE: { min: 1, max: 10 }, // Length |
9567011b | 238 | TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length |
2422c46b | 239 | DESCRIPTION: { min: 3, max: 10000 }, // Length |
d23e6a1c | 240 | SUPPORT: { min: 3, max: 1000 }, // Length |
ac81d1a0 C |
241 | IMAGE: { |
242 | EXTNAME: [ '.jpg', '.jpeg' ], | |
243 | FILE_SIZE: { | |
244 | max: 2 * 1024 * 1024 // 2MB | |
245 | } | |
246 | }, | |
536598cf | 247 | EXTNAME: [] as string[], |
0e1dc3e7 | 248 | INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 |
fbad87b0 | 249 | DURATION: { min: 0 }, // Number |
a265f7f3 C |
250 | TAGS: { min: 0, max: 5 }, // Number of total tags |
251 | TAG: { min: 2, max: 30 }, // Length | |
e4c55619 | 252 | THUMBNAIL: { min: 2, max: 30 }, |
e4c87ec2 C |
253 | THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes |
254 | VIEWS: { min: 0 }, | |
255 | LIKES: { min: 0 }, | |
93e1258c | 256 | DISLIKES: { min: 0 }, |
c60774b0 | 257 | FILE_SIZE: { min: 10 }, |
e34c85e5 C |
258 | URL: { min: 3, max: 2000 } // Length |
259 | }, | |
418d092a C |
260 | VIDEO_PLAYLISTS: { |
261 | NAME: { min: 1, max: 120 }, // Length | |
262 | DESCRIPTION: { min: 3, max: 1000 }, // Length | |
263 | URL: { min: 3, max: 2000 }, // Length | |
264 | IMAGE: { | |
265 | EXTNAME: [ '.jpg', '.jpeg' ], | |
266 | FILE_SIZE: { | |
267 | max: 2 * 1024 * 1024 // 2MB | |
268 | } | |
269 | } | |
270 | }, | |
01de67b9 | 271 | ACTORS: { |
e34c85e5 C |
272 | PUBLIC_KEY: { min: 10, max: 5000 }, // Length |
273 | PRIVATE_KEY: { min: 10, max: 5000 }, // Length | |
c5911fd3 C |
274 | URL: { min: 3, max: 2000 }, // Length |
275 | AVATAR: { | |
01de67b9 C |
276 | EXTNAME: [ '.png', '.jpeg', '.jpg' ], |
277 | FILE_SIZE: { | |
278 | max: 2 * 1024 * 1024 // 2MB | |
279 | } | |
c5911fd3 | 280 | } |
e4c87ec2 C |
281 | }, |
282 | VIDEO_EVENTS: { | |
283 | COUNT: { min: 0 } | |
6d852470 | 284 | }, |
bf1f6508 | 285 | VIDEO_COMMENTS: { |
b32b7827 | 286 | TEXT: { min: 1, max: 3000 }, // Length |
6d852470 | 287 | URL: { min: 3, max: 2000 } // Length |
4ba3b8ea C |
288 | }, |
289 | VIDEO_SHARE: { | |
290 | URL: { min: 3, max: 2000 } // Length | |
a4101923 C |
291 | }, |
292 | CONTACT_FORM: { | |
293 | FROM_NAME: { min: 1, max: 120 }, // Length | |
294 | BODY: { min: 3, max: 5000 } // Length | |
345da516 C |
295 | }, |
296 | PLUGINS: { | |
297 | NAME: { min: 1, max: 214 }, // Length | |
298 | DESCRIPTION: { min: 1, max: 20000 } // Length | |
2735a154 C |
299 | }, |
300 | COMMONS: { | |
301 | URL: { min: 5, max: 2000 } // Length | |
e4c55619 C |
302 | } |
303 | } | |
304 | ||
b5c0e955 | 305 | let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour |
a4101923 C |
306 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour |
307 | ||
edb4ffc7 | 308 | const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { |
a7977280 | 309 | MIN: 10, |
a1587156 C |
310 | STANDARD: [ 24, 25, 30 ], |
311 | HD_STANDARD: [ 50, 60 ], | |
3a6f351b C |
312 | AVERAGE: 30, |
313 | MAX: 60, | |
314 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: 720 // We keep the original FPS on high resolutions (720 minimum) | |
a7977280 | 315 | } |
b5c0e955 | 316 | |
536598cf C |
317 | const DEFAULT_AUDIO_RESOLUTION = VideoResolution.H_480P |
318 | ||
ee9e7b61 | 319 | const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = { |
d38b8281 C |
320 | LIKE: 'like', |
321 | DISLIKE: 'dislike' | |
322 | } | |
323 | ||
80bc88c1 J |
324 | const FFMPEG_NICE: { [ id: string ]: number } = { |
325 | THUMBNAIL: 2, // 2 just for don't blocking servers | |
326 | TRANSCODING: 15 | |
327 | } | |
328 | ||
6e07c3de C |
329 | const VIDEO_CATEGORIES = { |
330 | 1: 'Music', | |
331 | 2: 'Films', | |
332 | 3: 'Vehicles', | |
333 | 4: 'Art', | |
334 | 5: 'Sports', | |
335 | 6: 'Travels', | |
336 | 7: 'Gaming', | |
337 | 8: 'People', | |
338 | 9: 'Comedy', | |
339 | 10: 'Entertainment', | |
6f2ae7a1 | 340 | 11: 'News & Politics', |
40298b02 | 341 | 12: 'How To', |
6e07c3de C |
342 | 13: 'Education', |
343 | 14: 'Activism', | |
344 | 15: 'Science & Technology', | |
345 | 16: 'Animals', | |
346 | 17: 'Kids', | |
347 | 18: 'Food' | |
348 | } | |
349 | ||
6f0c39e2 C |
350 | // See https://creativecommons.org/licenses/?lang=en |
351 | const VIDEO_LICENCES = { | |
352 | 1: 'Attribution', | |
353 | 2: 'Attribution - Share Alike', | |
354 | 3: 'Attribution - No Derivatives', | |
355 | 4: 'Attribution - Non Commercial', | |
356 | 5: 'Attribution - Non Commercial - Share Alike', | |
357 | 6: 'Attribution - Non Commercial - No Derivatives', | |
358 | 7: 'Public Domain Dedication' | |
359 | } | |
360 | ||
a1587156 | 361 | const VIDEO_LANGUAGES: { [id: string]: string } = {} |
3092476e | 362 | |
fd45e8f4 | 363 | const VIDEO_PRIVACIES = { |
a1587156 C |
364 | [VideoPrivacy.PUBLIC]: 'Public', |
365 | [VideoPrivacy.UNLISTED]: 'Unlisted', | |
366 | [VideoPrivacy.PRIVATE]: 'Private', | |
367 | [VideoPrivacy.INTERNAL]: 'Internal' | |
fd45e8f4 C |
368 | } |
369 | ||
2186386c | 370 | const VIDEO_STATES = { |
a1587156 C |
371 | [VideoState.PUBLISHED]: 'Published', |
372 | [VideoState.TO_TRANSCODE]: 'To transcode', | |
373 | [VideoState.TO_IMPORT]: 'To import' | |
fbad87b0 C |
374 | } |
375 | ||
376 | const VIDEO_IMPORT_STATES = { | |
a1587156 C |
377 | [VideoImportState.FAILED]: 'Failed', |
378 | [VideoImportState.PENDING]: 'Pending', | |
379 | [VideoImportState.SUCCESS]: 'Success' | |
2186386c C |
380 | } |
381 | ||
268eebed | 382 | const VIDEO_ABUSE_STATES = { |
a1587156 C |
383 | [VideoAbuseState.PENDING]: 'Pending', |
384 | [VideoAbuseState.REJECTED]: 'Rejected', | |
385 | [VideoAbuseState.ACCEPTED]: 'Accepted' | |
268eebed C |
386 | } |
387 | ||
418d092a | 388 | const VIDEO_PLAYLIST_PRIVACIES = { |
a1587156 C |
389 | [VideoPlaylistPrivacy.PUBLIC]: 'Public', |
390 | [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', | |
391 | [VideoPlaylistPrivacy.PRIVATE]: 'Private' | |
418d092a C |
392 | } |
393 | ||
df0b219d | 394 | const VIDEO_PLAYLIST_TYPES = { |
a1587156 C |
395 | [VideoPlaylistType.REGULAR]: 'Regular', |
396 | [VideoPlaylistType.WATCH_LATER]: 'Watch later' | |
df0b219d C |
397 | } |
398 | ||
14e2014a | 399 | const MIMETYPES = { |
536598cf C |
400 | AUDIO: { |
401 | MIMETYPE_EXT: { | |
402 | 'audio/mpeg': '.mp3', | |
403 | 'audio/mp3': '.mp3', | |
404 | 'application/ogg': '.ogg', | |
405 | 'audio/ogg': '.ogg', | |
99d362de C |
406 | 'audio/x-ms-wma': '.wma', |
407 | 'audio/wav': '.wav', | |
408 | 'audio/x-flac': '.flac', | |
536598cf C |
409 | 'audio/flac': '.flac' |
410 | }, | |
411 | EXT_MIMETYPE: null as { [ id: string ]: string } | |
412 | }, | |
14e2014a | 413 | VIDEO: { |
536598cf | 414 | MIMETYPE_EXT: null as { [ id: string ]: string }, |
14e2014a C |
415 | EXT_MIMETYPE: null as { [ id: string ]: string } |
416 | }, | |
417 | IMAGE: { | |
418 | MIMETYPE_EXT: { | |
419 | 'image/png': '.png', | |
420 | 'image/jpg': '.jpg', | |
421 | 'image/jpeg': '.jpg' | |
c6de3a85 C |
422 | }, |
423 | EXT_MIMETYPE: null as { [ id: string ]: string } | |
14e2014a C |
424 | }, |
425 | VIDEO_CAPTIONS: { | |
426 | MIMETYPE_EXT: { | |
427 | 'text/vtt': '.vtt', | |
2f26030d C |
428 | 'application/x-subrip': '.srt', |
429 | 'text/plain': '.srt' | |
14e2014a C |
430 | } |
431 | }, | |
432 | TORRENT: { | |
433 | MIMETYPE_EXT: { | |
434 | 'application/x-bittorrent': '.torrent' | |
435 | } | |
436 | } | |
990b6a0b | 437 | } |
536598cf | 438 | MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT) |
c6de3a85 | 439 | MIMETYPES.IMAGE.EXT_MIMETYPE = invert(MIMETYPES.IMAGE.MIMETYPE_EXT) |
990b6a0b | 440 | |
9f6bae3a C |
441 | // --------------------------------------------------------------------------- |
442 | ||
2d3741d6 C |
443 | const OVERVIEWS = { |
444 | VIDEOS: { | |
1a471091 | 445 | SAMPLE_THRESHOLD: 6, |
764a9657 | 446 | SAMPLES_COUNT: 20 |
2d3741d6 C |
447 | } |
448 | } | |
449 | ||
a3ce4ae8 C |
450 | const VIDEO_CHANNELS = { |
451 | MAX_PER_USER: 20 | |
452 | } | |
453 | ||
2d3741d6 C |
454 | // --------------------------------------------------------------------------- |
455 | ||
50d6de9c | 456 | const SERVER_ACTOR_NAME = 'peertube' |
350e31d6 | 457 | |
e4f97bab | 458 | const ACTIVITY_PUB = { |
1b5b10d1 C |
459 | POTENTIAL_ACCEPT_HEADERS: [ |
460 | 'application/activity+json', | |
9a8cbd82 C |
461 | 'application/ld+json', |
462 | 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' | |
165cdc75 | 463 | ], |
1b5b10d1 | 464 | ACCEPT_HEADER: 'application/activity+json, application/ld+json', |
9a27cdc2 | 465 | PUBLIC: 'https://www.w3.org/ns/activitystreams#Public', |
0d0e8dd0 | 466 | COLLECTION_ITEMS_PER_PAGE: 10, |
4d9ae8f7 | 467 | FETCH_PAGE_LIMIT: 2000, |
20494f12 | 468 | URL_MIME_TYPES: { |
536598cf | 469 | VIDEO: [] as string[], |
20494f12 C |
470 | TORRENT: [ 'application/x-bittorrent' ], |
471 | MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ] | |
a5625b41 | 472 | }, |
2ccaeeb3 | 473 | MAX_RECURSION_COMMENTS: 100, |
0e0c745b | 474 | ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days |
9f79ade6 C |
475 | VIDEO_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days |
476 | VIDEO_PLAYLIST_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2 // 2 days | |
e4f97bab C |
477 | } |
478 | ||
50d6de9c C |
479 | const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = { |
480 | GROUP: 'Group', | |
481 | PERSON: 'Person', | |
47581df0 C |
482 | APPLICATION: 'Application', |
483 | ORGANIZATION: 'Organization', | |
484 | SERVICE: 'Service' | |
50d6de9c C |
485 | } |
486 | ||
41f2ebae C |
487 | const HTTP_SIGNATURE = { |
488 | HEADER_NAME: 'signature', | |
489 | ALGORITHM: 'rsa-sha256', | |
f67d7574 C |
490 | HEADERS_TO_SIGN: [ '(request-target)', 'host', 'date', 'digest' ], |
491 | CLOCK_SKEW_SECONDS: 1800 | |
41f2ebae C |
492 | } |
493 | ||
9f6bae3a C |
494 | // --------------------------------------------------------------------------- |
495 | ||
04b8c3fb | 496 | let PRIVATE_RSA_KEY_SIZE = 2048 |
bdfbd4f1 | 497 | |
9f6bae3a C |
498 | // Password encryption |
499 | const BCRYPT_SALT_SIZE = 10 | |
a877d5ac | 500 | |
f88ee4a9 | 501 | const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes |
45f1bd72 | 502 | const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days |
ecb4e35f | 503 | |
d9eaee39 JM |
504 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes |
505 | ||
6dd9de95 | 506 | const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { |
0883b324 C |
507 | DO_NOT_LIST: 'do_not_list', |
508 | BLUR: 'blur', | |
509 | DISPLAY: 'display' | |
510 | } | |
511 | ||
bdfbd4f1 C |
512 | // --------------------------------------------------------------------------- |
513 | ||
052937db C |
514 | // Express static paths (router) |
515 | const STATIC_PATHS = { | |
f285faa0 C |
516 | PREVIEWS: '/static/previews/', |
517 | THUMBNAILS: '/static/thumbnails/', | |
052937db | 518 | TORRENTS: '/static/torrents/', |
c5911fd3 | 519 | WEBSEED: '/static/webseed/', |
b9fffa29 | 520 | REDUNDANCY: '/static/redundancy/', |
9c6ca37f C |
521 | STREAMING_PLAYLISTS: { |
522 | HLS: '/static/streaming-playlists/hls' | |
09209296 | 523 | }, |
40e87e9e C |
524 | AVATARS: '/static/avatars/', |
525 | VIDEO_CAPTIONS: '/static/video-captions/' | |
052937db | 526 | } |
02756fbd C |
527 | const STATIC_DOWNLOAD_PATHS = { |
528 | TORRENTS: '/download/torrents/', | |
d7a25329 C |
529 | VIDEOS: '/download/videos/', |
530 | HLS_VIDEOS: '/download/streaming-playlists/hls/videos/' | |
02756fbd | 531 | } |
557b13ae C |
532 | const LAZY_STATIC_PATHS = { |
533 | AVATARS: '/lazy-static/avatars/', | |
534 | PREVIEWS: '/static/previews/', | |
535 | VIDEO_CAPTIONS: '/static/video-captions/' | |
536 | } | |
052937db | 537 | |
dc009132 | 538 | // Cache control |
a1587156 | 539 | const STATIC_MAX_AGE = { |
cd4cb177 C |
540 | SERVER: '2h', |
541 | CLIENT: '30d' | |
542 | } | |
dc009132 | 543 | |
cbe2f7c3 | 544 | // Videos thumbnail size |
d8755eed | 545 | const THUMBNAILS_SIZE = { |
e5fc7811 | 546 | width: 223, |
ca6d3622 C |
547 | height: 122, |
548 | minWidth: 150 | |
d8755eed C |
549 | } |
550 | const PREVIEWS_SIZE = { | |
b345a804 | 551 | width: 850, |
ca6d3622 C |
552 | height: 480, |
553 | minWidth: 400 | |
164174a6 | 554 | } |
e8e12200 C |
555 | const AVATARS_SIZE = { |
556 | width: 120, | |
557 | height: 120 | |
558 | } | |
164174a6 C |
559 | |
560 | const EMBED_SIZE = { | |
561 | width: 560, | |
562 | height: 315 | |
d8755eed | 563 | } |
cbe2f7c3 | 564 | |
980246ea | 565 | // Sub folders of cache directory |
d74d29ad | 566 | const FILES_CACHE = { |
f4001cf4 C |
567 | PREVIEWS: { |
568 | DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'previews'), | |
569 | MAX_AGE: 1000 * 3600 * 3 // 3 hours | |
570 | }, | |
571 | VIDEO_CAPTIONS: { | |
572 | DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'video-captions'), | |
573 | MAX_AGE: 1000 * 3600 * 3 // 3 hours | |
f981dae8 C |
574 | } |
575 | } | |
576 | ||
557b13ae | 577 | const LRU_CACHE = { |
d74d29ad | 578 | USER_TOKENS: { |
557b13ae C |
579 | MAX_SIZE: 1000 |
580 | }, | |
581 | AVATAR_STATIC: { | |
582 | MAX_SIZE: 500 | |
d74d29ad C |
583 | } |
584 | } | |
585 | ||
9c6ca37f | 586 | const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') |
09209296 C |
587 | const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') |
588 | ||
7348b1fd | 589 | const MEMOIZE_TTL = { |
35f28e94 C |
590 | OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours |
591 | INFO_HASH_EXISTS: 1000 * 3600 * 12 // 12 hours | |
592 | } | |
593 | ||
594 | const MEMOIZE_LENGTH = { | |
595 | INFO_HASH_EXISTS: 200 | |
7348b1fd C |
596 | } |
597 | ||
557b13ae C |
598 | const QUEUE_CONCURRENCY = { |
599 | AVATAR_PROCESS_IMAGE: 3 | |
600 | } | |
601 | ||
c48e82b5 C |
602 | const REDUNDANCY = { |
603 | VIDEOS: { | |
c48e82b5 C |
604 | RANDOMIZED_FACTOR: 5 |
605 | } | |
606 | } | |
607 | ||
e12a0092 | 608 | const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS) |
4f491371 | 609 | |
536598cf | 610 | const ASSETS_PATH = { |
fff2183d | 611 | DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg') |
536598cf C |
612 | } |
613 | ||
bdfbd4f1 C |
614 | // --------------------------------------------------------------------------- |
615 | ||
e032aec9 C |
616 | const CUSTOM_HTML_TAG_COMMENTS = { |
617 | TITLE: '<!-- title tag -->', | |
618 | DESCRIPTION: '<!-- description tag -->', | |
619 | CUSTOM_CSS: '<!-- custom css tag -->', | |
92bf2f62 | 620 | META_TAGS: '<!-- meta tags -->' |
e032aec9 | 621 | } |
709756b8 C |
622 | |
623 | // --------------------------------------------------------------------------- | |
624 | ||
4195cd2b | 625 | const FEEDS = { |
fd4484f1 | 626 | COUNT: 20 |
4195cd2b C |
627 | } |
628 | ||
fd8710b8 | 629 | const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000 |
566c125d C |
630 | const LOG_FILENAME = 'peertube.log' |
631 | const AUDIT_LOG_FILENAME = 'peertube-audit.log' | |
fd8710b8 | 632 | |
4195cd2b C |
633 | // --------------------------------------------------------------------------- |
634 | ||
9b67da3d C |
635 | const TRACKER_RATE_LIMITS = { |
636 | INTERVAL: 60000 * 5, // 5 minutes | |
8244c85a | 637 | ANNOUNCES_PER_IP_PER_INFOHASH: 15, // maximum announces per torrent in the interval |
9b67da3d C |
638 | ANNOUNCES_PER_IP: 30 // maximum announces for all our torrents in the interval |
639 | } | |
640 | ||
ae9bbed4 C |
641 | const P2P_MEDIA_LOADER_PEER_VERSION = 2 |
642 | ||
9b67da3d C |
643 | // --------------------------------------------------------------------------- |
644 | ||
345da516 C |
645 | const PLUGIN_GLOBAL_CSS_FILE_NAME = 'plugins-global.css' |
646 | const PLUGIN_GLOBAL_CSS_PATH = join(CONFIG.STORAGE.TMP_DIR, PLUGIN_GLOBAL_CSS_FILE_NAME) | |
647 | ||
ffb321be C |
648 | const DEFAULT_THEME_NAME = 'default' |
649 | const DEFAULT_USER_THEME_NAME = 'instance-default' | |
7cd4d2ba | 650 | |
345da516 C |
651 | // --------------------------------------------------------------------------- |
652 | ||
9f10b292 C |
653 | // Special constants for a test instance |
654 | if (isTestInstance() === true) { | |
04b8c3fb C |
655 | PRIVATE_RSA_KEY_SIZE = 1024 |
656 | ||
60650c77 | 657 | ACTOR_FOLLOW_SCORE.BASE = 20 |
3cd0734f | 658 | |
f285faa0 C |
659 | REMOTE_SCHEME.HTTP = 'http' |
660 | REMOTE_SCHEME.WS = 'ws' | |
3cd0734f | 661 | |
cd4cb177 | 662 | STATIC_MAX_AGE.SERVER = '0' |
3cd0734f | 663 | |
c46edbc2 | 664 | ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 |
7bc29171 | 665 | ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds |
1297eb5d | 666 | ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds |
9f79ade6 | 667 | ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds |
3cd0734f | 668 | |
01de67b9 | 669 | CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB |
3cd0734f | 670 | |
2f5c6b2f | 671 | SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 |
2baea0c7 | 672 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 |
8f0bc73d | 673 | SCHEDULER_INTERVALS_MS.removeOldHistory = 5000 |
cda03765 | 674 | SCHEDULER_INTERVALS_MS.removeOldViews = 5000 |
2baea0c7 | 675 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
6f1b4fa4 | 676 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 |
a1587156 | 677 | REPEAT_JOBS['videos-views'] = { every: 5000 } |
2baea0c7 | 678 | |
c48e82b5 C |
679 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
680 | ||
b5c0e955 | 681 | VIDEO_VIEW_LIFETIME = 1000 // 1 second |
a4101923 | 682 | CONTACT_FORM_LIFETIME = 1000 // 1 second |
3cd0734f | 683 | |
a1587156 | 684 | JOB_ATTEMPTS['email'] = 1 |
f4001cf4 | 685 | |
d74d29ad | 686 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
764a9657 C |
687 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 3000 |
688 | OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2 | |
9f10b292 C |
689 | } |
690 | ||
14e2014a | 691 | updateWebserverUrls() |
536598cf | 692 | updateWebserverConfig() |
225a89c2 | 693 | |
6dd9de95 C |
694 | registerConfigChangedHandler(() => { |
695 | updateWebserverUrls() | |
696 | updateWebserverConfig() | |
697 | }) | |
698 | ||
9f10b292 C |
699 | // --------------------------------------------------------------------------- |
700 | ||
65fcc311 | 701 | export { |
6dd9de95 | 702 | WEBSERVER, |
9f6bae3a | 703 | API_VERSION, |
66170ca8 | 704 | PEERTUBE_VERSION, |
557b13ae | 705 | LAZY_STATIC_PATHS, |
09209296 | 706 | HLS_REDUNDANCY_DIRECTORY, |
ae9bbed4 | 707 | P2P_MEDIA_LOADER_PEER_VERSION, |
e8e12200 | 708 | AVATARS_SIZE, |
4f491371 | 709 | ACCEPT_HEADERS, |
9f6bae3a | 710 | BCRYPT_SALT_SIZE, |
9b67da3d | 711 | TRACKER_RATE_LIMITS, |
d74d29ad | 712 | FILES_CACHE, |
566c125d | 713 | LOG_FILENAME, |
9f6bae3a | 714 | CONSTRAINTS_FIELDS, |
164174a6 | 715 | EMBED_SIZE, |
c48e82b5 | 716 | REDUNDANCY, |
94a5ff8a C |
717 | JOB_CONCURRENCY, |
718 | JOB_ATTEMPTS, | |
b769007f | 719 | LAST_MIGRATION_VERSION, |
9f6bae3a | 720 | OAUTH_LIFETIME, |
e032aec9 | 721 | CUSTOM_HTML_TAG_COMMENTS, |
f55e5a7b | 722 | BROADCAST_CONCURRENCY, |
566c125d | 723 | AUDIT_LOG_FILENAME, |
1194e8b4 | 724 | PAGINATION, |
60650c77 | 725 | ACTOR_FOLLOW_SCORE, |
f285faa0 C |
726 | PREVIEWS_SIZE, |
727 | REMOTE_SCHEME, | |
7a7724e6 | 728 | FOLLOW_STATES, |
6f1b4fa4 | 729 | INSTANCES_INDEX, |
ffb321be | 730 | DEFAULT_USER_THEME_NAME, |
50d6de9c | 731 | SERVER_ACTOR_NAME, |
345da516 C |
732 | PLUGIN_GLOBAL_CSS_FILE_NAME, |
733 | PLUGIN_GLOBAL_CSS_PATH, | |
e4f97bab | 734 | PRIVATE_RSA_KEY_SIZE, |
fd4484f1 | 735 | ROUTE_CACHE_LIFETIME, |
9f6bae3a | 736 | SORTABLE_COLUMNS, |
9c6ca37f | 737 | HLS_STREAMING_PLAYLIST_DIRECTORY, |
4195cd2b | 738 | FEEDS, |
2b86fe72 | 739 | JOB_TTL, |
ffb321be | 740 | DEFAULT_THEME_NAME, |
0883b324 | 741 | NSFW_POLICY_TYPES, |
dc009132 | 742 | STATIC_MAX_AGE, |
a6375e69 | 743 | STATIC_PATHS, |
cf9166cf | 744 | VIDEO_IMPORT_TIMEOUT, |
df0b219d | 745 | VIDEO_PLAYLIST_TYPES, |
fd8710b8 | 746 | MAX_LOGS_OUTPUT_CHARACTERS, |
e4f97bab | 747 | ACTIVITY_PUB, |
50d6de9c | 748 | ACTIVITY_PUB_ACTOR_TYPES, |
9f6bae3a | 749 | THUMBNAILS_SIZE, |
6e07c3de | 750 | VIDEO_CATEGORIES, |
35f28e94 | 751 | MEMOIZE_LENGTH, |
3092476e | 752 | VIDEO_LANGUAGES, |
fd45e8f4 | 753 | VIDEO_PRIVACIES, |
6f0c39e2 | 754 | VIDEO_LICENCES, |
2186386c | 755 | VIDEO_STATES, |
557b13ae | 756 | QUEUE_CONCURRENCY, |
0d0e8dd0 | 757 | VIDEO_RATE_TYPES, |
a7977280 | 758 | VIDEO_TRANSCODING_FPS, |
80bc88c1 | 759 | FFMPEG_NICE, |
268eebed | 760 | VIDEO_ABUSE_STATES, |
a3ce4ae8 | 761 | VIDEO_CHANNELS, |
557b13ae | 762 | LRU_CACHE, |
71e3dfda | 763 | JOB_REQUEST_TIMEOUT, |
ecb4e35f | 764 | USER_PASSWORD_RESET_LIFETIME, |
45f1bd72 | 765 | USER_PASSWORD_CREATE_LIFETIME, |
7348b1fd | 766 | MEMOIZE_TTL, |
d9eaee39 | 767 | USER_EMAIL_VERIFY_LIFETIME, |
2d3741d6 | 768 | OVERVIEWS, |
2baea0c7 | 769 | SCHEDULER_INTERVALS_MS, |
6b616860 | 770 | REPEAT_JOBS, |
02756fbd | 771 | STATIC_DOWNLOAD_PATHS, |
14e2014a | 772 | MIMETYPES, |
f6eebcb3 | 773 | CRAWL_REQUEST_CONCURRENCY, |
536598cf | 774 | DEFAULT_AUDIO_RESOLUTION, |
b5c0e955 | 775 | JOB_COMPLETED_LIFETIME, |
41f2ebae | 776 | HTTP_SIGNATURE, |
fbad87b0 | 777 | VIDEO_IMPORT_STATES, |
7ce44a74 | 778 | VIDEO_VIEW_LIFETIME, |
a4101923 | 779 | CONTACT_FORM_LIFETIME, |
418d092a | 780 | VIDEO_PLAYLIST_PRIVACIES, |
536598cf | 781 | ASSETS_PATH, |
74dc3bca | 782 | loadLanguages, |
7ce44a74 | 783 | buildLanguages |
9f10b292 | 784 | } |
fd206f0b C |
785 | |
786 | // --------------------------------------------------------------------------- | |
787 | ||
14e2014a C |
788 | function buildVideoMimetypeExt () { |
789 | const data = { | |
790 | 'video/webm': '.webm', | |
791 | 'video/ogg': '.ogv', | |
792 | 'video/mp4': '.mp4' | |
793 | } | |
794 | ||
536598cf C |
795 | if (CONFIG.TRANSCODING.ENABLED) { |
796 | if (CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS) { | |
797 | Object.assign(data, { | |
798 | 'video/quicktime': '.mov', | |
799 | 'video/x-msvideo': '.avi', | |
800 | 'video/x-flv': '.flv', | |
801 | 'video/x-matroska': '.mkv', | |
c37a52b0 C |
802 | 'video/avi': '.avi', |
803 | 'video/x-m4v': '.m4v', | |
26469f9e C |
804 | // Could be anything |
805 | 'application/octet-stream': null, | |
c37a52b0 | 806 | 'video/m4v': '.m4v' |
536598cf C |
807 | }) |
808 | } | |
809 | ||
810 | if (CONFIG.TRANSCODING.ALLOW_AUDIO_FILES) { | |
811 | Object.assign(data, MIMETYPES.AUDIO.MIMETYPE_EXT) | |
812 | } | |
14e2014a C |
813 | } |
814 | ||
815 | return data | |
816 | } | |
817 | ||
818 | function updateWebserverUrls () { | |
6dd9de95 C |
819 | WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) |
820 | WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) | |
821 | WEBSERVER.SCHEME = CONFIG.WEBSERVER.SCHEME | |
822 | WEBSERVER.WS = CONFIG.WEBSERVER.WS | |
823 | WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME | |
824 | WEBSERVER.PORT = CONFIG.WEBSERVER.PORT | |
fd206f0b C |
825 | } |
826 | ||
14e2014a | 827 | function updateWebserverConfig () { |
14e2014a C |
828 | MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt() |
829 | MIMETYPES.VIDEO.EXT_MIMETYPE = invert(MIMETYPES.VIDEO.MIMETYPE_EXT) | |
536598cf C |
830 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT) |
831 | ||
832 | CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = buildVideosExtname() | |
14e2014a C |
833 | } |
834 | ||
835 | function buildVideosExtname () { | |
536598cf | 836 | return Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE) |
14e2014a C |
837 | } |
838 | ||
74dc3bca | 839 | function loadLanguages () { |
8f0bc73d | 840 | Object.assign(VIDEO_LANGUAGES, buildLanguages()) |
74dc3bca C |
841 | } |
842 | ||
9d3ef9fe C |
843 | function buildLanguages () { |
844 | const iso639 = require('iso-639-3') | |
845 | ||
a1587156 | 846 | const languages: { [id: string]: string } = {} |
9d3ef9fe | 847 | |
1d94c154 | 848 | const additionalLanguages = { |
a1587156 C |
849 | sgn: true, // Sign languages (macro language) |
850 | ase: true, // American sign language | |
851 | sdl: true, // Arabian sign language | |
852 | bfi: true, // British sign language | |
853 | bzs: true, // Brazilian sign language | |
854 | csl: true, // Chinese sign language | |
855 | cse: true, // Czech sign language | |
856 | dsl: true, // Danish sign language | |
857 | fsl: true, // French sign language | |
858 | gsg: true, // German sign language | |
859 | pks: true, // Pakistan sign language | |
860 | jsl: true, // Japanese sign language | |
861 | sfs: true, // South African sign language | |
862 | swl: true, // Swedish sign language | |
863 | rsl: true, // Russian sign language: true | |
864 | ||
865 | epo: true, // Esperanto | |
866 | tlh: true, // Klingon | |
867 | jbo: true, // Lojban | |
868 | avk: true // Kotava | |
1d94c154 | 869 | } |
9d3ef9fe C |
870 | |
871 | // Only add ISO639-1 languages and some sign languages (ISO639-3) | |
872 | iso639 | |
873 | .filter(l => { | |
4fdeef81 | 874 | return (l.iso6391 !== undefined && l.type === 'living') || |
a1587156 | 875 | additionalLanguages[l.iso6393] === true |
9d3ef9fe | 876 | }) |
a1587156 | 877 | .forEach(l => { languages[l.iso6391 || l.iso6393] = l.name }) |
9d3ef9fe | 878 | |
db6d617d | 879 | // Override Occitan label |
a1587156 C |
880 | languages['oc'] = 'Occitan' |
881 | languages['el'] = 'Greek' | |
db6d617d | 882 | |
9d3ef9fe C |
883 | return languages |
884 | } |