communicate_email.rb 753 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
  3. observe 'ticket::_article'
  4. def after_create(record)
  5. # return if we run import mode
  6. return if Setting.get('import_mode')
  7. # if sender is customer, do not communication
  8. sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
  9. return 1 if sender == nil
  10. return 1 if sender['name'] == 'Customer'
  11. # only apply on emails
  12. type = Ticket::Article::Type.lookup( :id => record.type_id )
  13. return if type['name'] != 'email'
  14. # send background job
  15. Delayed::Job.enqueue( Observer::Ticket::Article::CommunicateEmail::BackgroundJob.new( record.id ) )
  16. end
  17. end