Skip to content

Commit

Permalink
Fix remote reporters not receiving suspend/unsuspend activities (mast…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and ClearlyClaire committed Jan 28, 2022
1 parent 47cab05 commit 4ea2c1d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
25 changes: 25 additions & 0 deletions app/lib/account_reach_finder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

class AccountReachFinder
def initialize(account)
@account = account
end

def inboxes
(followers_inboxes + reporters_inboxes + relay_inboxes).uniq
end

private

def followers_inboxes
@account.followers.inboxes
end

def reporters_inboxes
Account.where(id: @account.targeted_reports.select(:account_id)).inboxes
end

def relay_inboxes
Relay.enabled.pluck(:inbox_url)
end
end
12 changes: 11 additions & 1 deletion app/services/suspend_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ def reject_remote_follows!
end

def distribute_update_actor!
ActivityPub::UpdateDistributionWorker.perform_async(@account.id) if @account.local?
return unless @account.local?

account_reach_finder = AccountReachFinder.new(@account)

ActivityPub::DeliveryWorker.push_bulk(account_reach_finder.inboxes) do |inbox_url|
[signed_activity_json, @account.id, inbox_url]
end
end

def unmerge_from_home_timelines!
Expand Down Expand Up @@ -90,4 +96,8 @@ def privatize_media_attachments!
end
end
end

def signed_activity_json
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
end
end
15 changes: 15 additions & 0 deletions app/services/unsuspend_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def call(account)
merge_into_home_timelines!
merge_into_list_timelines!
publish_media_attachments!
distribute_update_actor!
end

private
Expand All @@ -36,6 +37,16 @@ def refresh_remote_account!
# @account would now be nil.
end

def distribute_update_actor!
return unless @account.local?

account_reach_finder = AccountReachFinder.new(@account)

ActivityPub::DeliveryWorker.push_bulk(account_reach_finder.inboxes) do |inbox_url|
[signed_activity_json, @account.id, inbox_url]
end
end

def merge_into_home_timelines!
@account.followers_for_local_distribution.find_each do |follower|
FeedManager.instance.merge_into_home(@account, follower)
Expand Down Expand Up @@ -81,4 +92,8 @@ def publish_media_attachments!
end
end
end

def signed_activity_json
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
end
end

0 comments on commit 4ea2c1d

Please sign in to comment.