From bf51ec3f5d14d88d7ac89351f2913081267824b2 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 14 Oct 2024 22:17:14 -0700 Subject: [PATCH] remove redundant params - forgot i subclassed --- app/services/activitypub/fetch_all_replies_service.rb | 2 +- app/services/activitypub/fetch_replies_service.rb | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/services/activitypub/fetch_all_replies_service.rb b/app/services/activitypub/fetch_all_replies_service.rb index 491a807bea5f27..09143127d5464f 100644 --- a/app/services/activitypub/fetch_all_replies_service.rb +++ b/app/services/activitypub/fetch_all_replies_service.rb @@ -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? diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 2963f616e2882b..bb20e666498668 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -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 @@ -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) @@ -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