appeal_service.rb 517 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.staff.includes(:account).each do |u|
  20. AdminMailer.new_appeal(u.account, @appeal).deliver_later if u.allows_appeal_emails?
  21. end
  22. end
  23. end