]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
Implement video comment list in admin
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index d1f94e6e6bea57435caccf1b428e21e979be1649..fde87d9f8a65b7a2d783d007639e08873b29dfa9 100644 (file)
@@ -1,29 +1,30 @@
-import { join } from 'path'
+import { randomInt } from '../../shared/core-utils/miscs/miscs'
+import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
 import { randomBytes } from 'crypto'
-import { ActivityPubActorType } from '../../shared/models/activitypub'
-import { FollowState } from '../../shared/models/actors'
+import { invert } from 'lodash'
+import { join } from 'path'
 import {
   AbuseState,
+  JobType,
   VideoImportState,
   VideoPrivacy,
-  VideoTranscodingFPS,
-  JobType,
   VideoRateType,
   VideoResolution,
-  VideoState
+  VideoState,
+  VideoTranscodingFPS
 } from '../../shared/models'
-// Do not use barrels, remain constants as independent as possible
-import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils'
+import { ActivityPubActorType } from '../../shared/models/activitypub'
+import { FollowState } from '../../shared/models/actors'
 import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
-import { invert } from 'lodash'
-import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
 import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
 import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
+// Do not use barrels, remain constants as independent as possible
+import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
 import { CONFIG, registerConfigChangedHandler } from './config'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 540
+const LAST_MIGRATION_VERSION = 550
 
 // ---------------------------------------------------------------------------
 
@@ -62,7 +63,10 @@ const SORTABLE_COLUMNS = {
   JOBS: [ 'createdAt' ],
   VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
   VIDEO_IMPORTS: [ 'createdAt' ],
+
   VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ],
+  VIDEO_COMMENTS: [ 'createdAt' ],
+
   VIDEO_RATES: [ 'createdAt' ],
   BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
   FOLLOWERS: [ 'createdAt', 'state', 'score' ],
@@ -172,7 +176,7 @@ const JOB_TTL: { [id in JobType]: number } = {
 }
 const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = {
   'videos-views': {
-    cron: '1 * * * *' // At 1 minute past the hour
+    cron: randomInt(1, 20) + ' * * * *' // Between 1-20 minutes past the hour
   }
 }
 
@@ -316,7 +320,11 @@ const CONSTRAINTS_FIELDS = {
   }
 }
 
-let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour
+const VIEW_LIFETIME = {
+  VIDEO: 60000 * 60, // 1 hour
+  LIVE: 60000 * 5 // 5 minutes
+}
+
 let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
 
 const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
@@ -508,6 +516,10 @@ const HTTP_SIGNATURE = {
   HEADER_NAME: 'signature',
   ALGORITHM: 'rsa-sha256',
   HEADERS_TO_SIGN: [ '(request-target)', 'host', 'date', 'digest' ],
+  REQUIRED_HEADERS: {
+    ALL: [ '(request-target)', 'host', 'date' ],
+    POST: [ '(request-target)', 'host', 'date', 'digest' ]
+  },
   CLOCK_SKEW_SECONDS: 1800
 }
 
@@ -611,6 +623,7 @@ const VIDEO_LIVE = {
   CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes
   SEGMENT_TIME_SECONDS: 4, // 4 seconds
   SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist
+  EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION: 3,
   RTMP: {
     CHUNK_SIZE: 60000,
     GOP_CACHE: true,
@@ -672,7 +685,7 @@ const TRACKER_RATE_LIMITS = {
   INTERVAL: 60000 * 5, // 5 minutes
   ANNOUNCES_PER_IP_PER_INFOHASH: 15, // maximum announces per torrent in the interval
   ANNOUNCES_PER_IP: 30, // maximum announces for all our torrents in the interval
-  BLOCK_IP_LIFETIME: 60000 * 10 // 10 minutes
+  BLOCK_IP_LIFETIME: 60000 * 3 // 3 minutes
 }
 
 const P2P_MEDIA_LOADER_PEER_VERSION = 2
@@ -710,9 +723,9 @@ if (isTestInstance() === true) {
   STATIC_MAX_AGE.SERVER = '0'
 
   ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
-  ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 100 * 10000 // 10 seconds
-  ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 100 * 10000 // 10 seconds
-  ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 100 * 10000 // 10 seconds
+  ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
+  ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
+  ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
 
   CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB
 
@@ -726,7 +739,8 @@ if (isTestInstance() === true) {
 
   REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
 
-  VIDEO_VIEW_LIFETIME = 1000 // 1 second
+  VIEW_LIFETIME.VIDEO = 1000 // 1 second
+  VIEW_LIFETIME.LIVE = 1000 * 5 // 5 second
   CONTACT_FORM_LIFETIME = 1000 // 1 second
 
   JOB_ATTEMPTS['email'] = 1
@@ -740,6 +754,7 @@ if (isTestInstance() === true) {
 
   VIDEO_LIVE.CLEANUP_DELAY = 5000
   VIDEO_LIVE.SEGMENT_TIME_SECONDS = 2
+  VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
 }
 
 updateWebserverUrls()
@@ -838,7 +853,7 @@ export {
   JOB_COMPLETED_LIFETIME,
   HTTP_SIGNATURE,
   VIDEO_IMPORT_STATES,
-  VIDEO_VIEW_LIFETIME,
+  VIEW_LIFETIME,
   CONTACT_FORM_LIFETIME,
   VIDEO_PLAYLIST_PRIVACIES,
   PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME,
@@ -924,7 +939,6 @@ function updateWebserverUrls () {
   WEBSERVER.SCHEME = CONFIG.WEBSERVER.SCHEME
   WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME
   WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
-  WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
 
   WEBSERVER.RTMP_URL = 'rtmp://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
 }