Fixed reminder notifications.

This commit is contained in:
Martin Edenhofer 2016-02-22 13:54:28 +01:00
parent 50971e4425
commit 2d4b7dab56
2 changed files with 5 additions and 4 deletions

View file

@ -140,7 +140,7 @@ class Observer::Ticket::Notification::BackgroundJob
next if history['type'] != 'notification' next if history['type'] != 'notification'
next if history['value_to'] !~ /\(#{Regexp.escape(@p[:type])}:/ next if history['value_to'] !~ /\(#{Regexp.escape(@p[:type])}:/
next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/ next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/
next if history['created_at'].today? next if !history['created_at'].today?
already_notified = true already_notified = true
} }
next if already_notified next if already_notified
@ -154,7 +154,7 @@ class Observer::Ticket::Notification::BackgroundJob
# delete old notifications # delete old notifications
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation' if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation'
seen = false seen = false
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type]) OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type], user)
# on updates without state changes create unseen messages # on updates without state changes create unseen messages
elsif @p[:type] != 'create' && (!@p[:changes] || @p[:changes].empty? || !@p[:changes]['state_id']) elsif @p[:type] != 'create' && (!@p[:changes] || @p[:changes].empty? || !@p[:changes]['state_id'])

View file

@ -88,17 +88,18 @@ remove whole online notifications of an object
remove whole online notifications of an object by type remove whole online notifications of an object by type
OnlineNotification.remove_by_type('Ticket', 123, type) OnlineNotification.remove_by_type('Ticket', 123, type, user)
=end =end
def self.remove_by_type(object_name, o_id, type) def self.remove_by_type(object_name, o_id, type, user)
object_id = ObjectLookup.by_name(object_name) object_id = ObjectLookup.by_name(object_name)
type_id = TypeLookup.by_name(type) type_id = TypeLookup.by_name(type)
OnlineNotification.where( OnlineNotification.where(
object_lookup_id: object_id, object_lookup_id: object_id,
type_lookup_id: type_id, type_lookup_id: type_id,
o_id: o_id, o_id: o_id,
user_id: user.id,
).destroy_all ).destroy_all
end end