diff options
author | ThibG <thib@sitedethib.com> | 2020-11-09 11:30:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-09 11:30:28 +0100 |
commit | 67125534bc0fd48a45d6cb17a5c78712d8e87150 (patch) | |
tree | b718c8b54a0bd63eab69abaef2267c8f0aa9a9b9 /app/services/suspend_account_service.rb | |
parent | cfb16b9b70a50ec5451c9aebb2c35d3a44701311 (diff) | |
parent | ecd83f495c18486bc7ea901423f6fccfd910b277 (diff) |
Merge pull request #1454 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services/suspend_account_service.rb')
-rw-r--r-- | app/services/suspend_account_service.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index f08c41e17..7c70a6021 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -1,10 +1,14 @@ # frozen_string_literal: true class SuspendAccountService < BaseService + include Payloadable + def call(account) @account = account suspend! + reject_remote_follows! + distribute_update_actor! unmerge_from_home_timelines! unmerge_from_list_timelines! privatize_media_attachments! @@ -16,6 +20,31 @@ class SuspendAccountService < BaseService @account.suspend! unless @account.suspended? end + def reject_remote_follows! + return if @account.local? || !@account.activitypub? + + # When suspending a remote account, the account obviously doesn't + # actually become suspended on its origin server, i.e. unlike a + # locally suspended account it continues to have access to its home + # feed and other content. To prevent it from being able to continue + # to access toots it would receive because it follows local accounts, + # we have to force it to unfollow them. Unfortunately, there is no + # counterpart to this operation, i.e. you can't then force a remote + # account to re-follow you, so this part is not reversible. + + follows = Follow.where(account: @account).to_a + + ActivityPub::DeliveryWorker.push_bulk(follows) do |follow| + [Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), follow.target_account_id, @account.inbox_url] + end + + follows.each(&:destroy) + end + + def distribute_update_actor! + ActivityPub::UpdateDistributionWorker.perform_async(@account.id) if @account.local? + end + def unmerge_from_home_timelines! @account.followers_for_local_distribution.find_each do |follower| FeedManager.instance.unmerge_from_home(@account, follower) |