communicate_facebook.rb 796 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Ticket::Article::CommunicateFacebook < 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'] != 'facebook'
  14. a = Channel::Facebook.new
  15. a.send(
  16. {
  17. :from => 'me@znuny.com',
  18. :to => 'medenhofer',
  19. :body => record.body
  20. }
  21. )
  22. end
  23. end