Improved notifications.
This commit is contained in:
parent
682bd223a8
commit
d147aedde6
1 changed files with 34 additions and 21 deletions
|
@ -8,10 +8,19 @@ class Ticket::Observer::Notification < ActiveRecord::Observer
|
||||||
# puts '@@event_buffer'
|
# puts '@@event_buffer'
|
||||||
# puts @@event_buffer.inspect
|
# puts @@event_buffer.inspect
|
||||||
@@event_buffer.each { |event|
|
@@event_buffer.each { |event|
|
||||||
if event[:name] == 'Ticket' && event[:type] == 'create'
|
|
||||||
ticket = Ticket.find( event[:id] )
|
|
||||||
|
|
||||||
# send new ticket notification to agents
|
# get current state ob objects
|
||||||
|
if event[:name] == 'Ticket::Article'
|
||||||
|
article = Ticket::Article.find( event[:id] )
|
||||||
|
ticket = article.ticket
|
||||||
|
else
|
||||||
|
ticket = Ticket.find( event[:id] )
|
||||||
|
article = ticket.articles[-1]
|
||||||
|
end
|
||||||
|
|
||||||
|
# send new ticket notification to agents
|
||||||
|
if event[:name] == 'Ticket' && event[:type] == 'create'
|
||||||
|
|
||||||
puts 'send new ticket notify to agent'
|
puts 'send new ticket notify to agent'
|
||||||
send_notify(
|
send_notify(
|
||||||
{
|
{
|
||||||
|
@ -20,21 +29,27 @@ class Ticket::Observer::Notification < ActiveRecord::Observer
|
||||||
:subject => 'New Ticket (#{ticket.title})',
|
:subject => 'New Ticket (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
:body => 'Hi #{recipient.firstname},
|
||||||
|
|
||||||
a new Ticket (#{ticket.title}) in Group #{ticket.group.name}
|
a new Ticket (#{ticket.title}) in Group #{ticket.group.name}, owned by #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
|
|
||||||
From: #{ticket.articles[-1].from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{ticket.articles[-1].body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{ticket.articles[-1].id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
nil
|
article
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# send new ticket notification to customers
|
||||||
|
if event[:name] == 'Ticket' && event[:type] == 'create'
|
||||||
|
|
||||||
|
# only for incoming emails
|
||||||
|
next if article.ticket_article_type.name != 'email'
|
||||||
|
|
||||||
# send new ticket notification to customers
|
|
||||||
puts 'send new ticket notify to customer'
|
puts 'send new ticket notify to customer'
|
||||||
send_notify(
|
send_notify(
|
||||||
{
|
{
|
||||||
|
@ -45,7 +60,7 @@ From: #{ticket.articles[-1].from}
|
||||||
|
|
||||||
You wrote:
|
You wrote:
|
||||||
<snip>
|
<snip>
|
||||||
#{ticket.articles[-1].body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
Your email will be answered by a human ASAP
|
Your email will be answered by a human ASAP
|
||||||
|
@ -56,14 +71,12 @@ Your Zammad Team
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
nil
|
article
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# send follow up notification
|
# send follow up notification
|
||||||
if event[:name] == 'Ticket::Article' && event[:type] == 'create'
|
if event[:name] == 'Ticket::Article' && event[:type] == 'create'
|
||||||
article = Ticket::Article.find( event[:id] )
|
|
||||||
ticket = article.ticket
|
|
||||||
|
|
||||||
# only send article notifications after init article is created (handled by ticket create event)
|
# only send article notifications after init article is created (handled by ticket create event)
|
||||||
next if ticket.articles.count >= 1
|
next if ticket.articles.count >= 1
|
||||||
|
@ -78,14 +91,14 @@ Your Zammad Team
|
||||||
:subject => 'Follow Up (#{ticket.title})',
|
:subject => 'Follow Up (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
:body => 'Hi #{recipient.firstname},
|
||||||
|
|
||||||
a follow Up (#{ticket.title}) in Group #{ticket.group.name}
|
a follow Up (#{ticket.title}) in Group #{ticket.group.name}, owned by #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
|
|
||||||
From: #{ticket.articles[-1].from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{ticket.articles[-1].body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{ticket.articles[-1].id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
|
@ -103,14 +116,14 @@ From: #{ticket.articles[-1].from}
|
||||||
:subject => 'Updated (#{ticket.title})',
|
:subject => 'Updated (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
:body => 'Hi #{recipient.firstname},
|
||||||
|
|
||||||
Updated (#{ticket.title}) in Group #{ticket.group.name}
|
Updated (#{ticket.title}) in Group #{ticket.group.name}, owned by #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
|
|
||||||
From: #{ticket.articles[-1].from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{ticket.articles[-1].body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{ticket.articles[-1].id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
|
|
Loading…
Reference in a new issue