]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
Avoid making retried requests to dead followers
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index c902e0cf69fdde0314a3c77a477cd31bd116385d..eda3403f25592aa31747a5924b1a3a3d5297fed9 100644 (file)
@@ -9,7 +9,7 @@ import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 165
+const LAST_MIGRATION_VERSION = 170
 
 // ---------------------------------------------------------------------------
 
@@ -40,12 +40,12 @@ const OAUTH_LIFETIME = {
 
 // ---------------------------------------------------------------------------
 
-// Number of points we add/remove from a friend after a successful/bad request
-const SERVERS_SCORE = {
+// Number of points we add/remove after a successful/bad request
+const ACTOR_FOLLOW_SCORE = {
   PENALTY: -10,
   BONUS: 10,
-  BASE: 100,
-  MAX: 1000
+  BASE: 1000,
+  MAX: 10000
 }
 
 const FOLLOW_STATES: { [ id: string ]: FollowState } = {
@@ -76,6 +76,9 @@ const JOBS_FETCH_LIMIT_PER_CYCLE = {
 // 1 minutes
 let JOBS_FETCHING_INTERVAL = 60000
 
+// 1 hour
+let SCHEDULER_INTERVAL = 60000 * 60
+
 // ---------------------------------------------------------------------------
 
 const CONFIG = {
@@ -267,7 +270,8 @@ const SERVER_ACTOR_NAME = 'peertube'
 const ACTIVITY_PUB = {
   POTENTIAL_ACCEPT_HEADERS: [
     'application/activity+json',
-    'application/ld+json'
+    'application/ld+json',
+    'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
   ],
   ACCEPT_HEADER: 'application/activity+json, application/ld+json',
   PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
@@ -279,7 +283,8 @@ const ACTIVITY_PUB = {
     TORRENT: [ 'application/x-bittorrent' ],
     MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
   },
-  ACTOR_REFRESH_INTERVAL: 3600 * 24 // 1 day
+  MAX_RECURSION_COMMENTS: 100,
+  ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000 // 1 day
 }
 
 const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = {
@@ -345,14 +350,15 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
 
 // Special constants for a test instance
 if (isTestInstance() === true) {
-  SERVERS_SCORE.BASE = 20
+  ACTOR_FOLLOW_SCORE.BASE = 20
   JOBS_FETCHING_INTERVAL = 1000
   REMOTE_SCHEME.HTTP = 'http'
   REMOTE_SCHEME.WS = 'ws'
   STATIC_MAX_AGE = '0'
   ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
-  ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 60 // 1 minute
+  ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
   CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB
+  SCHEDULER_INTERVAL = 10000
 }
 
 CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT)
@@ -377,7 +383,7 @@ export {
   OAUTH_LIFETIME,
   OPENGRAPH_AND_OEMBED_COMMENT,
   PAGINATION_COUNT_DEFAULT,
-  SERVERS_SCORE,
+  ACTOR_FOLLOW_SCORE,
   PREVIEWS_SIZE,
   REMOTE_SCHEME,
   FOLLOW_STATES,
@@ -395,5 +401,6 @@ export {
   VIDEO_LICENCES,
   VIDEO_RATE_TYPES,
   VIDEO_MIMETYPE_EXT,
-  AVATAR_MIMETYPE_EXT
+  AVATAR_MIMETYPE_EXT,
+  SCHEDULER_INTERVAL
 }