You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
835 B

  1. # frozen_string_literal: true
  2. class UnblockService < BaseService
  3. def call(account, target_account)
  4. return unless account.blocking?(target_account)
  5. unblock = account.unblock!(target_account)
  6. NotificationWorker.perform_async(build_xml(unblock), account.id, target_account.id) unless target_account.local?
  7. end
  8. private
  9. def build_xml(block)
  10. Nokogiri::XML::Builder.new do |xml|
  11. entry(xml, true) do
  12. unique_id xml, Time.now.utc, block.id, 'Block'
  13. title xml, "#{block.account.acct} no longer blocks #{block.target_account.acct}"
  14. author(xml) do
  15. include_author xml, block.account
  16. end
  17. object_type xml, :activity
  18. verb xml, :unblock
  19. target(xml) do
  20. include_author xml, block.target_account
  21. end
  22. end
  23. end.to_xml
  24. end
  25. end