mirror of https://github.com/mastodon/mastodon
make filter_by_host a private method
This commit is contained in:
parent
e27a890e70
commit
d7a60dcd4b
|
@ -8,7 +8,6 @@ class ActivityPub::FetchAllRepliesService < ActivityPub::FetchRepliesService
|
|||
|
||||
def call(collection_or_uri, status_uri, max_pages = nil, request_id: nil)
|
||||
@allow_synchronous_requests = true
|
||||
@filter_by_host = false
|
||||
@collection_or_uri = collection_or_uri
|
||||
@status_uri = status_uri
|
||||
|
||||
|
@ -62,4 +61,8 @@ class ActivityPub::FetchAllRepliesService < ActivityPub::FetchRepliesService
|
|||
Rails.logger.debug { "FetchAllRepliesService - #{@collection_or_uri}: Fetching filtered statuses: #{uris}" }
|
||||
uris
|
||||
end
|
||||
|
||||
def filter_by_host?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,9 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
# Limit of fetched replies
|
||||
MAX_REPLIES = 5
|
||||
|
||||
def call(parent_status, collection_or_uri, allow_synchronous_requests: true, request_id: nil, filter_by_host: true)
|
||||
def call(parent_status, collection_or_uri, allow_synchronous_requests: true, request_id: nil)
|
||||
@account = parent_status.account
|
||||
@allow_synchronous_requests = allow_synchronous_requests
|
||||
@filter_by_host = filter_by_host
|
||||
|
||||
@items, = collection_items(collection_or_uri)
|
||||
return if @items.nil?
|
||||
|
@ -53,7 +52,7 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
def fetch_collection(collection_or_uri)
|
||||
return collection_or_uri if collection_or_uri.is_a?(Hash)
|
||||
return unless @allow_synchronous_requests
|
||||
return if @filter_by_host && non_matching_uri_hosts?(@account.uri, collection_or_uri)
|
||||
return if filter_by_host? && non_matching_uri_hosts?(@account.uri, collection_or_uri)
|
||||
|
||||
# NOTE: For backward compatibility reasons, Mastodon signs outgoing
|
||||
# queries incorrectly by default.
|
||||
|
@ -72,7 +71,7 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
end
|
||||
|
||||
def filtered_replies
|
||||
if @filter_by_host
|
||||
if filter_by_host?
|
||||
# Only fetch replies to the same server as the original status to avoid
|
||||
# amplification attacks.
|
||||
|
||||
|
@ -82,4 +81,9 @@ class ActivityPub::FetchRepliesService < BaseService
|
|||
@items.map { |item| value_or_id(item) }.take(MAX_REPLIES)
|
||||
end
|
||||
end
|
||||
|
||||
# Whether replies with a different domain than the replied_to post should be rejected
|
||||
def filter_by_host?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue