Skip to content

Commit

Permalink
make limits configurable too while we're at it
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Oct 20, 2024
1 parent cc1a1be commit f6c0079
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,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
Expand Down
2 changes: 1 addition & 1 deletion app/services/activitypub/fetch_all_replies_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/workers/activitypub/fetch_all_replies_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f6c0079

Please sign in to comment.