mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 15:09:29 +00:00
Remove severed relationship notifications for single account suspensions (#29700)
This commit is contained in:
parent
70a8fcf07d
commit
05eda8d193
|
@ -8,7 +8,6 @@ class SuspendAccountService < BaseService
|
||||||
def call(account)
|
def call(account)
|
||||||
return unless account.suspended?
|
return unless account.suspended?
|
||||||
|
|
||||||
@relationship_severance_event = nil
|
|
||||||
@account = account
|
@account = account
|
||||||
|
|
||||||
reject_remote_follows!
|
reject_remote_follows!
|
||||||
|
@ -16,7 +15,6 @@ class SuspendAccountService < BaseService
|
||||||
unmerge_from_home_timelines!
|
unmerge_from_home_timelines!
|
||||||
unmerge_from_list_timelines!
|
unmerge_from_list_timelines!
|
||||||
privatize_media_attachments!
|
privatize_media_attachments!
|
||||||
notify_of_severed_relationships!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -38,8 +36,6 @@ class SuspendAccountService < BaseService
|
||||||
[Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
[Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url]
|
||||||
end
|
end
|
||||||
|
|
||||||
relationship_severance_event.import_from_passive_follows!(follows)
|
|
||||||
|
|
||||||
follows.each(&:destroy)
|
follows.each(&:destroy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -105,21 +101,7 @@ class SuspendAccountService < BaseService
|
||||||
end
|
end
|
||||||
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
|
def signed_activity_json
|
||||||
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
@signed_activity_json ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account))
|
||||||
end
|
end
|
||||||
|
|
||||||
def relationship_severance_event
|
|
||||||
@relationship_severance_event ||= RelationshipSeveranceEvent.create!(type: :account_suspension, target_name: @account.acct)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,14 +85,10 @@ RSpec.describe SuspendAccountService, :sidekiq_inline do
|
||||||
account.follow!(local_followee)
|
account.follow!(local_followee)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends a Reject Follow activity, and records severed relationships', :aggregate_failures do
|
it 'sends a Reject Follow activity', :aggregate_failures do
|
||||||
subject
|
subject
|
||||||
|
|
||||||
expect(a_request(:post, account.inbox_url).with { |req| match_reject_follow_request(req, account, local_followee) }).to have_been_made.once
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue