logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

reject.rb (627B)


  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Reject < ActivityPub::Activity
  3. def perform
  4. case @object['type']
  5. when 'Follow'
  6. reject_follow
  7. end
  8. end
  9. private
  10. def reject_follow
  11. target_account = account_from_uri(target_uri)
  12. return if target_account.nil? || !target_account.local?
  13. follow_request = FollowRequest.find_by(account: target_account, target_account: @account)
  14. follow_request&.reject!
  15. UnfollowService.new.call(target_account, @account) if target_account.following?(@account)
  16. end
  17. def target_uri
  18. @target_uri ||= value_or_id(@object['actor'])
  19. end
  20. end