From a8fd1fbab76f2a655bb1e0796af32a77e1e14515 Mon Sep 17 00:00:00 2001 From: "KMY (Yuki Asuka)" Date: Sun, 21 Jun 2026 18:03:13 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=E3=83=AA=E3=83=AC=E3=83=BC=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E4=B8=AD=E3=81=AE=E3=82=B5=E3=83=BC?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=81=8B=E3=82=89=E3=83=96=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=8C=E5=B1=8A=E3=81=8F=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/activitypub/activity/announce.rb | 5 ++++ .../lib/activitypub/activity/announce_spec.rb | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/app/lib/activitypub/activity/announce.rb b/app/lib/activitypub/activity/announce.rb index a6650a0a9e6ce6..096714c0cd1ade 100644 --- a/app/lib/activitypub/activity/announce.rb +++ b/app/lib/activitypub/activity/announce.rb @@ -6,6 +6,7 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity def perform return reject_payload! if delete_arrived_first?(@json['id']) || !related_to_local_activity? return reject_payload! if @object.nil? + return reject_payload! if reject_relay? with_redis_lock("announce:#{value_or_id(@object)}") do original_status = status_from_object @@ -88,4 +89,8 @@ def requested_through_relay? def reblog_of_local_status? status_from_uri(object_uri)&.account&.local? end + + def reject_relay? + requested_through_relay? && DomainBlock.reject_relay?(@account.domain) + end end diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index 51e4dacaf53bb8..fa4cf913ebd87b 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -143,6 +143,21 @@ end end + context 'without rejecting relay received from no-relay' do + let(:object_json) do + ActivityPub::TagManager.instance.uri_for(status) + end + + before do + Fabricate(:domain_block, domain: sender.domain, reject_relay: true) + subject.perform + end + + it 'creates a reblog' do + expect(sender.reblogged?(status)).to be true + end + end + context 'when the sender is relayed' do subject { described_class.new(json, sender, relayed_through_actor: relay_account) } @@ -167,6 +182,18 @@ end end + context 'with rejecting relay' do + before do + Fabricate(:domain_block, domain: sender.domain, reject_relay: true) + relay.update(state: :accepted) + subject.perform + end + + it 'does not reblog' do + expect(sender.statuses.count).to eq 0 + end + end + context 'when the relay is disabled' do before do subject.perform