So not set pending reminder online notifications to seen.
This commit is contained in:
parent
77fedbe108
commit
08bd5186b7
3 changed files with 19 additions and 4 deletions
|
@ -145,6 +145,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
|
||||||
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type])
|
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type])
|
||||||
end
|
end
|
||||||
OnlineNotification.add(
|
OnlineNotification.add(
|
||||||
|
|
|
@ -278,13 +278,16 @@ returns
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def online_notification_seen_state(user_id_check = nil)
|
def online_notification_seen_state(user_id_check = nil)
|
||||||
|
|
||||||
# always to set unseen for ticket owner
|
|
||||||
return false if user_id_check && user_id_check == owner_id && user_id_check != updated_by_id
|
|
||||||
|
|
||||||
state = Ticket::State.lookup(id: state_id)
|
state = Ticket::State.lookup(id: state_id)
|
||||||
state_type = Ticket::StateType.lookup(id: state.state_type_id)
|
state_type = Ticket::StateType.lookup(id: state.state_type_id)
|
||||||
|
|
||||||
|
# always to set unseen for ticket owner
|
||||||
|
if state_type.name != 'merged'
|
||||||
|
if user_id_check
|
||||||
|
return false if user_id_check == owner_id && user_id_check != updated_by_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# set all to seen if pending action state is a closed or merged state
|
# set all to seen if pending action state is a closed or merged state
|
||||||
if state_type.name == 'pending action' && state.next_state_id
|
if state_type.name == 'pending action' && state.next_state_id
|
||||||
state = Ticket::State.lookup(id: state.next_state_id)
|
state = Ticket::State.lookup(id: state.next_state_id)
|
||||||
|
|
|
@ -427,6 +427,17 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), true)
|
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), true)
|
||||||
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
|
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
|
||||||
|
|
||||||
|
# to closed by owner self, all to seen
|
||||||
|
ticket1.update_attributes(
|
||||||
|
owner_id: agent_user1.id,
|
||||||
|
state: Ticket::State.lookup(name: 'merged'),
|
||||||
|
updated_by_id: agent_user2.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_equal(ticket1.online_notification_seen_state, true)
|
||||||
|
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), true)
|
||||||
|
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def notification_check(online_notifications, checks)
|
def notification_check(online_notifications, checks)
|
||||||
|
|
Loading…
Reference in a new issue