enqueue_communicate_sms_job.rb 887 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. # Schedules a backgrond communication job for new SMS articles.
  3. module Ticket::Article::EnqueueCommunicateSmsJob
  4. extend ActiveSupport::Concern
  5. included do
  6. after_create :ticket_article_enqueue_communicate_sms_job
  7. end
  8. private
  9. def ticket_article_enqueue_communicate_sms_job
  10. # return if we run import mode
  11. return true if Setting.get('import_mode')
  12. # if sender is customer, do not communicate
  13. return true if !sender_id
  14. sender = Ticket::Article::Sender.lookup(id: sender_id)
  15. return true if sender.nil?
  16. return true if sender.name == 'Customer'
  17. # only apply on sms
  18. return true if !type_id
  19. type = Ticket::Article::Type.lookup(id: type_id)
  20. return true if type.nil?
  21. return true if type.name != 'sms'
  22. CommunicateSmsJob.perform_later(id)
  23. end
  24. end