Added escalation notification.

This commit is contained in:
Martin Edenhofer 2016-02-23 00:28:13 +01:00
parent fa653b3743
commit 91dc89c32b
10 changed files with 153 additions and 19 deletions

View file

@ -154,6 +154,7 @@ class App.OnlineNotificationWidget extends App.Controller
title = item.objectNative.activityMessage(item)
else
title = "Need objectNative in item #{item.object}.find(#{item.o_id})"
title = title.replace(/<.+?>/g, '"')
@notifyDesktop(
url: item.link
title: title

View file

@ -130,7 +130,7 @@ class Observer::Ticket::Notification::BackgroundJob
next if @p[:type] == 'update' && !article && ( !changes || changes.empty? )
# check if today already notified
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation'
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation' || @p[:type] == 'escalation_warning'
identifier = user.email
if !identifier || identifier == ''
identifier = user.login
@ -154,11 +154,17 @@ class Observer::Ticket::Notification::BackgroundJob
created_by_id = ticket.updated_by_id || 1
# delete old notifications
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation'
if @p[:type] == 'reminder_reached'
seen = false
created_by_id = 1
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type], user)
elsif @p[:type] == 'escalation' || @p[:type] == 'escalation_warning'
seen = false
created_by_id = 1
OnlineNotification.remove_by_type('Ticket', ticket.id, 'escalation', user)
OnlineNotification.remove_by_type('Ticket', ticket.id, 'escalation_warning', user)
# on updates without state changes create unseen messages
elsif @p[:type] != 'create' && (!@p[:changes] || @p[:changes].empty? || !@p[:changes]['state_id'])
seen = false
@ -197,6 +203,8 @@ class Observer::Ticket::Notification::BackgroundJob
template = 'ticket_reminder_reached'
elsif @p[:type] == 'escalation'
template = 'ticket_escalation'
elsif @p[:type] == 'escalation_warning'
template = 'ticket_escalation_warning'
else
fail "unknown type for notification #{@p[:type]}"
end

View file

@ -126,7 +126,7 @@ returns
processes tickets which have reached their pending time and sets next state_id
processed_tickets = Ticket.process_pending()
processed_tickets = Ticket.process_pending
returns
@ -196,6 +196,54 @@ returns
=begin
processes escalated tickets
processed_tickets = Ticket.process_escalation
returns
processed_tickets = [<Ticket>, ...]
=end
def self.process_escalation
result = []
# get max warning diff
tickets = where('escalation_time <= ?', Time.zone.now + 15.minutes)
tickets.each {|ticket|
# get sla
sla = ticket.escalation_calculation_get_sla
# send escalation
if ticket.escalation_time < Time.zone.now
bg = Observer::Ticket::Notification::BackgroundJob.new(
ticket_id: ticket.id,
article_id: ticket.articles.last.id,
type: 'escalation',
)
bg.perform
result.push ticket
next
end
# check if warning need to be sent
bg = Observer::Ticket::Notification::BackgroundJob.new(
ticket_id: ticket.id,
article_id: ticket.articles.last.id,
type: 'escalation_warning',
)
bg.perform
result.push ticket
}
result
end
=begin
merge tickets
ticket = Ticket.find(123)

View file

@ -0,0 +1,18 @@
Ticket ist eskaliert (<%= d 'ticket.title' %>)
<p>Hallo <%= d 'recipient.firstname' %>,</p>
<br>
<p>Ticket (<%= d 'ticket.title' %>) von "<b><%= d 'ticket.customer.longname' %></b>" ist seit "<%= d 'ticket.escalation_time' %>" eskaliert!</p>
<br>
<% if @objects[:article] %>
<p>
<%= t 'Information' %>:
<blockquote type="cite">
<%= a 'article' %>
</blockquote>
</p>
<% end %>
<br>
<p>
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>" target="zammad_app"><%= t 'View this in Zammad' %></a>
</p>

View file

@ -0,0 +1,18 @@
Ticket is escalated (<%= d 'ticket.title' %>)
<p>Hi <%= d 'recipient.firstname' %>,</p>
<br>
<p>Ticket (<%= d 'ticket.title' %>) from "<b><%= d 'ticket.customer.longname' %></b>" is escalated since "<%= d 'ticket.escalation_time' %>"!</p>
<br>
<% if @objects[:article] %>
<p>
<%= t 'Information' %>:
<blockquote type="cite">
<%= a 'article' %>
</blockquote>
</p>
<% end %>
<br>
<p>
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>" target="zammad_app"><%= t 'View this in Zammad' %></a>
</p>

View file

@ -0,0 +1,18 @@
Ticket wird eskalieren (<%= d 'ticket.title' %>)
<p>Hallo <%= d 'recipient.firstname' %>,</p>
<br>
<p>Ticket (<%= d 'ticket.title' %>) von "<b><%= d 'ticket.customer.longname' %></b>" wird um "<%= d 'ticket.escalation_time' %>" eskalieren!</p>
<br>
<% if @objects[:article] %>
<p>
<%= t 'Information' %>:
<blockquote type="cite">
<%= a 'article' %>
</blockquote>
</p>
<% end %>
<br>
<p>
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>" target="zammad_app"><%= t 'View this in Zammad' %></a>
</p>

View file

@ -0,0 +1,18 @@
Ticket will escalated (<%= d 'ticket.title' %>)
<p>Hi <%= d 'recipient.firstname' %>,</p>
<br>
<p>Ticket (<%= d 'ticket.title' %>) from "<b><%= d 'ticket.customer.longname' %></b>" will escalated at "<%= d 'ticket.escalation_time' %>"!</p>
<br>
<% if @objects[:article] %>
<p>
<%= t 'Information' %>:
<blockquote type="cite">
<%= a 'article' %>
</blockquote>
</p>
<% end %>
<br>
<p>
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#ticket/zoom/<%= d 'ticket.id' %>" target="zammad_app"><%= t 'View this in Zammad' %></a>
</p>

View file

@ -1,15 +0,0 @@
class UpdateChannel2 < ActiveRecord::Migration
def up
Scheduler.create_or_update(
name: 'Check streams for Channel ',
method: 'Channel.stream',
period: 60,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
end
end

View file

@ -0,0 +1,13 @@
class AddProcessEscalationTickets < ActiveRecord::Migration
def up
Scheduler.create_if_not_exists(
name: 'Process escalation tickets',
method: 'Ticket.process_escalation',
period: 60 * 5,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
end
end

View file

@ -3301,6 +3301,13 @@ Scheduler.create_if_not_exists(
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Process escalation tickets',
method: 'Ticket.process_escalation',
period: 60 * 5,
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Import OTRS diff load',
method: 'Import::OTRS.diff_worker',
@ -3320,7 +3327,7 @@ Scheduler.create_if_not_exists(
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Check streams for Channel ',
name: 'Check streams for Channel',
method: 'Channel.stream',
period: 60,
prio: 1,