trabajo-afectivo/app/models/observer/ticket/article/communicate_twitter.rb

24 lines
718 B
Ruby
Raw Normal View History

2014-02-03 19:23:00 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::CommunicateTwitter < 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-12-14 09:23:14 +00:00
sender = Ticket::Article::Sender.lookup(id: record.sender_id)
2015-07-02 15:13:04 +00:00
return if sender.nil?
return if sender['name'] == 'Customer'
# only apply on tweets
2015-12-14 09:23:14 +00:00
type = Ticket::Article::Type.lookup(id: record.type_id)
return if type['name'] !~ /\Atwitter/i
Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateTwitter::BackgroundJob.new(record.id))
end
2015-12-14 09:23:14 +00:00
end