diff --git a/.env.production.sample b/.env.production.sample index 39818ccfeaa13a..10a74401b05926 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -313,6 +313,13 @@ FETCH_REPLIES_DEBOUNCE=15 # Period to wait after a post is first created before fetching its replies (in minutes) FETCH_REPLIES_CREATED_RECENTLY=5 +# Max number of replies to fetch - total, recursively through a whole reply tree +FETCH_REPLIES_MAX_GLOBAL=1000 + +# Max number of replies to fetch - for a single post +FETCH_REPLIES_MAX_SINGLE=500 + + # IP and session retention # ----------------------- # Make sure to modify the scheduling of ip_cleanup_scheduler in config/sidekiq.yml diff --git a/app/services/activitypub/fetch_all_replies_service.rb b/app/services/activitypub/fetch_all_replies_service.rb index 292d5aad301c01..491a807bea5f27 100644 --- a/app/services/activitypub/fetch_all_replies_service.rb +++ b/app/services/activitypub/fetch_all_replies_service.rb @@ -4,7 +4,7 @@ class ActivityPub::FetchAllRepliesService < ActivityPub::FetchRepliesService include JsonLdHelper # Limit of replies to fetch per status - MAX_REPLIES = 500 + MAX_REPLIES = (ENV['FETCH_REPLIES_MAX_SINGLE'] || 500).to_i def call(collection_or_uri, allow_synchronous_requests: true, request_id: nil) @allow_synchronous_requests = allow_synchronous_requests diff --git a/app/workers/activitypub/fetch_all_replies_worker.rb b/app/workers/activitypub/fetch_all_replies_worker.rb index c739cafbb183ac..b641ef62bcb4b7 100644 --- a/app/workers/activitypub/fetch_all_replies_worker.rb +++ b/app/workers/activitypub/fetch_all_replies_worker.rb @@ -12,7 +12,7 @@ class ActivityPub::FetchAllRepliesWorker sidekiq_options queue: 'pull', retry: 3 # Global max replies to fetch per request (all replies, recursively) - MAX_REPLIES = 1000 + MAX_REPLIES = (ENV['FETCH_REPLIES_MAX_GLOBAL'] || 1000).to_i def perform(parent_status_id, options = {}) @parent_status = Status.find(parent_status_id)