Fix lax relevancy check in inbound activity processing (#39892)

This commit is contained in:
Claire
2026-07-22 18:39:38 +02:00
parent af8d57c886
commit 61a1238bd7
3 changed files with 33 additions and 28 deletions
+22 -18
View File
@@ -15,7 +15,17 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
private
def create_status
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity?
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists?
@status_parser = ActivityPub::Parser::StatusParser.new(
@json,
followers_collection: @account.followers_url,
following_collection: @account.following_url,
actor_uri: ActivityPub::TagManager.instance.uri_for(@account),
object: @object
)
return reject_payload! unless related_to_local_activity?
with_redis_lock("create:#{object_uri}") do
Status.uncached do
@@ -34,13 +44,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
@status
end
def audience_to
as_array(@object['to'] || @json['to']).map { |x| value_or_id(x) }
end
def audience_cc
as_array(@object['cc'] || @json['cc']).map { |x| value_or_id(x) }
end
delegate :audience_to, :audience_cc, to: :@status_parser
def process_status
@tags = []
@@ -91,14 +95,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
def process_status_params
@status_parser = ActivityPub::Parser::StatusParser.new(
@json,
followers_collection: @account.followers_url,
following_collection: @account.following_url,
actor_uri: ActivityPub::TagManager.instance.uri_for(@account),
object: @object
)
attachment_ids = process_attachments.take(Status::MEDIA_ATTACHMENTS_LIMIT).map(&:id)
@params = {
@@ -454,8 +450,16 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
def related_to_local_activity?
fetch? || followed_by_local_accounts? || requested_through_relay? ||
responds_to_followed_account? || addresses_local_accounts?
return true if fetch?
case @status_parser.visibility
when :public, :unlisted
followed_by_local_accounts? || requested_through_relay? || responds_to_followed_account? || addresses_local_accounts?
when :private
followed_by_local_accounts? || addresses_local_accounts?
when :direct
addresses_local_accounts?
end
end
def responds_to_followed_account?
+8 -8
View File
@@ -166,6 +166,14 @@ class ActivityPub::Parser::StatusParser
equals_or_includes_any?(@object['type'], ActivityPub::Activity::CONVERTED_TYPES)
end
def audience_to
as_array(@object['to'] || @json['to']).map { |x| value_or_id(x) }
end
def audience_cc
as_array(@object['cc'] || @json['cc']).map { |x| value_or_id(x) }
end
private
def quote_subpolicy(subpolicy)
@@ -197,14 +205,6 @@ class ActivityPub::Parser::StatusParser
end
end
def audience_to
as_array(@object['to'] || @json['to']).map { |x| value_or_id(x) }
end
def audience_cc
as_array(@object['cc'] || @json['cc']).map { |x| value_or_id(x) }
end
def summary_language_map?
@object['summaryMap'].is_a?(Hash) && !@object['summaryMap'].empty?
end