diff options
author | Takeshi Umeda <noel.yoshiba@gmail.com> | 2021-10-18 19:02:35 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 12:02:35 +0200 |
commit | 17f4e457b3a909522a230fd1f1f8f737e3faad87 (patch) | |
tree | a43668d4509e3e0ba9d0b0e17ea548a3901eb07e /app/services | |
parent | 766a361b86f8c8212c08d3bae1d4728c3c5b1f09 (diff) |
Add remove from followers api (#16864)
* Add followed_by? to account_interactions * Add RemoveFromFollowersService * Fix AccountBatch to use RemoveFromFollowersService * Add remove from followers API
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/remove_from_followers_service.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/services/remove_from_followers_service.rb b/app/services/remove_from_followers_service.rb new file mode 100644 index 000000000..3dac5467f --- /dev/null +++ b/app/services/remove_from_followers_service.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class RemoveFromFollowersService < BaseService + include Payloadable + + def call(source_account, target_accounts) + source_account.passive_relationships.where(account_id: target_accounts).find_each do |follow| + follow.destroy + + if source_account.local? && !follow.account.local? && follow.account.activitypub? + create_notification(follow) + end + end + end + + private + + def create_notification(follow) + ActivityPub::DeliveryWorker.perform_async(build_json(follow), follow.target_account_id, follow.account.inbox_url) + end + + def build_json(follow) + Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)) + end +end |