Remove severed relationship notifications for single account suspensions (#29700)

main
Claire 2024-03-21 22:53:24 +01:00 committed by GitHub
parent 70a8fcf07d
commit 05eda8d193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 23 deletions

View File

@ -8,7 +8,6 @@ class SuspendAccountService < BaseService
def call(account)
return unless account.suspended?
@relationship_severance_event = nil
@account = account
reject_remote_follows!
@ -16,7 +15,6 @@ class SuspendAccountService < BaseService
unmerge_from_home_timelines!
unmerge_from_list_timelines!
privatize_media_attachments!
notify_of_severed_relationships!
end
private
@ -38,8 +36,6 @@ class SuspendAccountService < BaseService
[Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
end
relationship_severance_event.import_from_passive_follows!(follows)
follows.each(&:destroy)
end
end
@ -105,21 +101,7 @@ class SuspendAccountService < BaseService
end
end
def notify_of_severed_relationships!
return if @relationship_severance_event.nil?
# TODO: check how efficient that query is, also check `push_bulk`/`perform_bulk`
@relationship_severance_event.affected_local_accounts.reorder(nil).find_each do |account|
event = AccountRelationshipSeveranceEvent.create!(account: account, relationship_severance_event: @relationship_severance_event)
LocalNotificationWorker.perform_async(account.id, event.id, 'AccountRelationshipSeveranceEvent', 'severed_relationships')
end
end
def signed_activity_json
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
end
def relationship_severance_event
@relationship_severance_event ||= RelationshipSeveranceEvent.create!(type: :account_suspension, target_name: @account.acct)
end
end

View File

@ -85,14 +85,10 @@ RSpec.describe SuspendAccountService, :sidekiq_inline do
account.follow!(local_followee)
end
it 'sends a Reject Follow activity, and records severed relationships', :aggregate_failures do
it 'sends a Reject Follow activity', :aggregate_failures do
subject
expect(a_request(:post, account.inbox_url).with { |req| match_reject_follow_request(req, account, local_followee) }).to have_been_made.once
severed_relationships = local_followee.severed_relationships.to_a
expect(severed_relationships.count).to eq 1
expect(severed_relationships.map { |rel| [rel.account, rel.target_account] }).to contain_exactly([account, local_followee])
end
end
end