From 2d4b7dab56d6bbf1aacf79e177f7c647c9a54ce7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 22 Feb 2016 13:54:28 +0100 Subject: [PATCH] Fixed reminder notifications. --- app/models/observer/ticket/notification/background_job.rb | 4 ++-- app/models/online_notification.rb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb index d1bce42e2..304987106 100644 --- a/app/models/observer/ticket/notification/background_job.rb +++ b/app/models/observer/ticket/notification/background_job.rb @@ -140,7 +140,7 @@ class Observer::Ticket::Notification::BackgroundJob next if history['type'] != 'notification' next if history['value_to'] !~ /\(#{Regexp.escape(@p[:type])}:/ next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/ - next if history['created_at'].today? + next if !history['created_at'].today? already_notified = true } next if already_notified @@ -154,7 +154,7 @@ class Observer::Ticket::Notification::BackgroundJob # delete old notifications if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation' 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 elsif @p[:type] != 'create' && (!@p[:changes] || @p[:changes].empty? || !@p[:changes]['state_id']) diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 7f96a2a54..69508555b 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -88,17 +88,18 @@ remove whole online notifications of an object 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 - 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) type_id = TypeLookup.by_name(type) OnlineNotification.where( object_lookup_id: object_id, type_lookup_id: type_id, o_id: o_id, + user_id: user.id, ).destroy_all end