]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
Handle reports from mastodon
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index 4163fe49da7a14b689053b220003ce873a3d6bbf..908231a88551a3ff8a75d664daef5a63dc94b246 100644 (file)
@@ -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,