2014-02-03 19:23:00 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-12-24 13:55:43 +00:00
|
|
|
class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
|
|
|
|
observe 'ticket::_article'
|
|
|
|
|
|
|
|
def after_create(record)
|
|
|
|
|
|
|
|
# return if we run import mode
|
|
|
|
return if Setting.get('import_mode')
|
|
|
|
|
|
|
|
# if sender is customer, do not communication
|
2015-04-27 13:42:53 +00:00
|
|
|
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
|
2015-05-07 10:11:45 +00:00
|
|
|
return 1 if sender.nil?
|
2012-12-24 13:55:43 +00:00
|
|
|
return 1 if sender['name'] == 'Customer'
|
|
|
|
|
|
|
|
# only apply on emails
|
2015-04-27 13:42:53 +00:00
|
|
|
type = Ticket::Article::Type.lookup( id: record.type_id )
|
2012-12-24 13:55:43 +00:00
|
|
|
return if type['name'] != 'facebook'
|
|
|
|
|
|
|
|
a = Channel::Facebook.new
|
|
|
|
a.send(
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
from: 'me@znuny.com',
|
|
|
|
to: 'medenhofer',
|
|
|
|
body: record.body
|
2012-12-24 13:55:43 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|