1
0

appeal_service.rb 563 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. class AppealService < BaseService
  3. def call(strike, text)
  4. @strike = strike
  5. @text = text
  6. create_appeal!
  7. notify_staff!
  8. @appeal
  9. end
  10. private
  11. def create_appeal!
  12. @appeal = Appeal.create!(
  13. strike: @strike,
  14. text: @text,
  15. account: @strike.target_account
  16. )
  17. end
  18. def notify_staff!
  19. User.those_who_can(:manage_appeals).includes(:account).find_each do |u|
  20. AdminMailer.with(recipient: u.account).new_appeal(@appeal).deliver_later if u.allows_appeal_emails?
  21. end
  22. end
  23. end