From 17f4e457b3a909522a230fd1f1f8f737e3faad87 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Mon, 18 Oct 2021 19:02:35 +0900 Subject: Add remove from followers api (#16864) * Add followed_by? to account_interactions * Add RemoveFromFollowersService * Fix AccountBatch to use RemoveFromFollowersService * Add remove from followers API --- app/models/concerns/account_interactions.rb | 4 ++++ app/models/form/account_batch.rb | 12 +----------- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb index 8f19176a7..ad1665dc4 100644 --- a/app/models/concerns/account_interactions.rb +++ b/app/models/concerns/account_interactions.rb @@ -195,6 +195,10 @@ module AccountInteractions !following_anyone? end + def followed_by?(other_account) + other_account.following?(self) + end + def blocking?(other_account) block_relationships.where(target_account: other_account).exists? end diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb index 698933c9f..f1e1c8a65 100644 --- a/app/models/form/account_batch.rb +++ b/app/models/form/account_batch.rb @@ -43,9 +43,7 @@ class Form::AccountBatch end def remove_from_followers! - current_account.passive_relationships.where(account_id: account_ids).find_each do |follow| - reject_follow!(follow) - end + RemoveFromFollowersService.new.call(current_account, account_ids) end def block_domains! @@ -62,14 +60,6 @@ class Form::AccountBatch Account.where(id: account_ids) end - def reject_follow!(follow) - follow.destroy - - return unless follow.account.activitypub? - - ActivityPub::DeliveryWorker.perform_async(Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), current_account.id, follow.account.inbox_url) - end - def approve! users = accounts.includes(:user).map(&:user) -- cgit