Skip to content

Commit

Permalink
remove redundant params - forgot i subclassed
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Oct 20, 2024
1 parent f6c0079 commit ab35055
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
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 @@ -10,7 +10,7 @@ def call(collection_or_uri, allow_synchronous_requests: true, request_id: nil)
@allow_synchronous_requests = allow_synchronous_requests
@filter_by_host = false

@items = collection_items(collection_or_uri, fetch_all: true)
@items = collection_items(collection_or_uri)
@items = filtered_replies
return if @items.nil?

Expand Down
7 changes: 2 additions & 5 deletions app/services/activitypub/fetch_replies_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class ActivityPub::FetchRepliesService < BaseService

# Limit of fetched replies
MAX_REPLIES = 5
# Limit when fetching all (to prevent infinite fetch attack)
FETCH_ALL_MAX_REPLIES = 500

def call(parent_status, collection_or_uri, allow_synchronous_requests: true, request_id: nil, filter_by_host: true)
@account = parent_status.account
Expand All @@ -23,7 +21,7 @@ def call(parent_status, collection_or_uri, allow_synchronous_requests: true, req

private

def collection_items(collection_or_uri, fetch_all: false)
def collection_items(collection_or_uri)
collection = fetch_collection(collection_or_uri)
return unless collection.is_a?(Hash)

Expand All @@ -41,8 +39,7 @@ def collection_items(collection_or_uri, fetch_all: false)

all_items.concat(as_array(items))

# Quit early if we are not fetching all replies or we've reached the absolute max
break if (!fetch_all && all_items.size >= MAX_REPLIES) || (all_items.size >= FETCH_ALL_MAX_REPLIES)
break if all_items.size > MAX_REPLIES

collection = collection['next'].present? ? fetch_collection(collection['next']) : nil
end
Expand Down

0 comments on commit ab35055

Please sign in to comment.