Moved to background jobs for mail sending.

This commit is contained in:
Martin Edenhofer 2014-02-03 19:34:32 +01:00
parent eb47a0c2c8
commit eb0a4bd7a9

View file

@ -17,6 +17,13 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
return if type['name'] != 'email'
Delayed::Job.enqueue( Observer::Ticket::Article::CommunicateEmail::Send.new( record.id )
end
class Send < Struct.new( :id )
def perform
record = Ticket::Article.find( id )
# build subject
ticket = Ticket.lookup( :id => record.ticket_id )
subject = ticket.subject_build( record.subject )
@ -69,4 +76,6 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
)
end
end
end
end