X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=908231a88551a3ff8a75d664daef5a63dc94b246;hb=0b5c385b4529f3bef8f9523de3f9470ffa58f5f5;hp=4163fe49da7a14b689053b220003ce873a3d6bbf;hpb=ad91e7006e41f8ee5b8dcefee30f99e8ca44133a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 4163fe49d..908231a88 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -4,7 +4,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub' import { FollowState } from '../../shared/models/actors' import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' // Do not use barrels, remain constants as independent as possible -import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils' +import { isTestInstance, sanitizeHost, sanitizeUrl, root, parseDurationToMs } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' import { CronRepeatOptions, EveryRepeatOptions } from 'bull' @@ -14,12 +14,12 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 400 +const LAST_MIGRATION_VERSION = 425 // --------------------------------------------------------------------------- -// API version const API_VERSION = 'v1' +const PEERTUBE_VERSION = require(join(root(), 'package.json')).version const PAGINATION = { COUNT: { @@ -39,7 +39,7 @@ const WEBSERVER = { // Sortable columns per schema const SORTABLE_COLUMNS = { - USERS: [ 'id', 'username', 'createdAt' ], + USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt' ], USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ], ACCOUNTS: [ 'createdAt' ], JOBS: [ 'createdAt' ], @@ -64,7 +64,9 @@ const SORTABLE_COLUMNS = { VIDEO_PLAYLISTS: [ 'displayName', 'createdAt', 'updatedAt' ], - PLUGINS: [ 'name', 'createdAt', 'updatedAt' ] + PLUGINS: [ 'name', 'createdAt', 'updatedAt' ], + + AVAILABLE_PLUGINS: [ 'npmName', 'popularity' ] } const OAUTH_LIFETIME = { @@ -165,13 +167,14 @@ const SCHEDULER_INTERVALS_MS = { removeOldJobs: 60000 * 60, // 1 hour updateVideos: 60000, // 1 minute youtubeDLUpdate: 60000 * 60 * 24, // 1 day + checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, removeOldViews: 60000 * 60 * 24, // 1 day removeOldHistory: 60000 * 60 * 24 // 1 day } // --------------------------------------------------------------------------- -let CONSTRAINTS_FIELDS = { +const CONSTRAINTS_FIELDS = { USERS: { NAME: { min: 1, max: 120 }, // Length DESCRIPTION: { min: 3, max: 1000 }, // Length @@ -495,9 +498,17 @@ const STATIC_DOWNLOAD_PATHS = { TORRENTS: '/download/torrents/', VIDEOS: '/download/videos/' } +const LAZY_STATIC_PATHS = { + AVATARS: '/lazy-static/avatars/', + PREVIEWS: '/static/previews/', + VIDEO_CAPTIONS: '/static/video-captions/' +} // Cache control -let STATIC_MAX_AGE = '2h' +let STATIC_MAX_AGE = { + SERVER: '2h', + CLIENT: '30d' +} // Videos thumbnail size const THUMBNAILS_SIZE = { @@ -530,9 +541,12 @@ const FILES_CACHE = { } } -const CACHE = { +const LRU_CACHE = { USER_TOKENS: { - MAX_SIZE: 10000 + MAX_SIZE: 1000 + }, + AVATAR_STATIC: { + MAX_SIZE: 500 } } @@ -543,6 +557,10 @@ const MEMOIZE_TTL = { OVERVIEWS_SAMPLE: 1000 * 3600 * 4 // 4 hours } +const QUEUE_CONCURRENCY = { + AVATAR_PROCESS_IMAGE: 3 +} + const REDUNDANCY = { VIDEOS: { RANDOMIZED_FACTOR: 5 @@ -601,7 +619,7 @@ if (isTestInstance() === true) { REMOTE_SCHEME.HTTP = 'http' REMOTE_SCHEME.WS = 'ws' - STATIC_MAX_AGE = '0' + STATIC_MAX_AGE.SERVER = '0' ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds @@ -642,6 +660,8 @@ registerConfigChangedHandler(() => { export { WEBSERVER, API_VERSION, + PEERTUBE_VERSION, + LAZY_STATIC_PATHS, HLS_REDUNDANCY_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, AVATARS_SIZE, @@ -688,11 +708,12 @@ export { VIDEO_PRIVACIES, VIDEO_LICENCES, VIDEO_STATES, + QUEUE_CONCURRENCY, VIDEO_RATE_TYPES, VIDEO_TRANSCODING_FPS, FFMPEG_NICE, VIDEO_ABUSE_STATES, - CACHE, + LRU_CACHE, JOB_REQUEST_TIMEOUT, USER_PASSWORD_RESET_LIFETIME, MEMOIZE_TTL,