diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index f53c0f06b6..c36e7edb8b 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -46,6 +46,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity def create_status return reject_payload! if unsupported_object_type? || invalid_origin?(object_uri) || tombstone_exists? || !related_to_local_activity? + return reject_payload! if (reply_to_local? || reply_to_local_account?) && reject_reply_to_local? with_lock("create:#{object_uri}") do return if delete_arrived_first?(object_uri) || poll_vote? @@ -136,7 +137,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity } end - def process_audience + def reply_to_local_account? + accounts_in_audience.any? { |account| account.local? } + end + + def accounts_in_audience + return @accounts_in_audience if @accounts_in_audience + # Unlike with tags, there is no point in resolving accounts we don't already # know here, because silent mentions would only be used for local access control anyway accounts_in_audience = (audience_to + audience_cc).uniq.filter_map do |audience| @@ -150,6 +157,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity accounts_in_audience.uniq! end + return @accounts_in_audience = accounts_in_audience + end + + def process_audience accounts_in_audience.each do |account| # This runs after tags are processed, and those translate into non-silent # mentions, which take precedence