Fixes #3471 - Mention does not notify users without full permission on group.
This commit is contained in:
parent
7d881b7253
commit
6ed3445207
2 changed files with 35 additions and 1 deletions
|
@ -76,7 +76,7 @@ returns
|
|||
end
|
||||
|
||||
# check if group is in selected groups
|
||||
if !owned_by_me
|
||||
if !owned_by_me && !subscribed
|
||||
selected_group_ids = user_preferences['notification_config']['group_ids']
|
||||
if selected_group_ids.is_a?(Array)
|
||||
hit = nil
|
||||
|
|
|
@ -1543,14 +1543,26 @@ RSpec.describe Ticket, type: :model do
|
|||
'escalation' => { 'criteria' => { 'owned_by_me' => false, 'owned_by_nobody' => false, 'subscribed' => true, 'no' => false }, 'channel' => { 'email' => false, 'online' => false } } } } }
|
||||
end
|
||||
|
||||
let(:prefs_matrix_only_mentions_groups) do
|
||||
{ 'notification_config' =>
|
||||
{ 'matrix' =>
|
||||
{ 'create' => { 'criteria' => { 'owned_by_me' => false, 'owned_by_nobody' => false, 'subscribed' => true, 'no' => false }, 'channel' => { 'email' => true, 'online' => true } },
|
||||
'update' => { 'criteria' => { 'owned_by_me' => false, 'owned_by_nobody' => false, 'subscribed' => true, 'no' => false }, 'channel' => { 'email' => true, 'online' => true } },
|
||||
'reminder_reached' => { 'criteria' => { 'owned_by_me' => false, 'owned_by_nobody' => false, 'subscribed' => true, 'no' => false }, 'channel' => { 'email' => false, 'online' => false } },
|
||||
'escalation' => { 'criteria' => { 'owned_by_me' => false, 'owned_by_nobody' => false, 'subscribed' => true, 'no' => false }, 'channel' => { 'email' => false, 'online' => false } } },
|
||||
'group_ids' => [create(:group).id, create(:group).id, create(:group).id] } }
|
||||
end
|
||||
|
||||
let(:mention_group) { create(:group) }
|
||||
let(:no_access_group) { create(:group) }
|
||||
let(:user_only_mentions) { create(:agent, groups: [mention_group], preferences: prefs_matrix_only_mentions) }
|
||||
let(:user_read_mentions) { create(:agent, groups: [mention_group], preferences: prefs_matrix_only_mentions_groups) }
|
||||
let(:user_no_mentions) { create(:agent, groups: [mention_group], preferences: prefs_matrix_no_mentions) }
|
||||
let(:ticket) { create(:ticket, group: mention_group, owner: user_no_mentions) }
|
||||
|
||||
it 'does inform mention user about the ticket update' do
|
||||
create(:mention, mentionable: ticket, user: user_only_mentions)
|
||||
create(:mention, mentionable: ticket, user: user_read_mentions)
|
||||
create(:mention, mentionable: ticket, user: user_no_mentions)
|
||||
Observer::Transaction.commit
|
||||
Scheduler.worker(true)
|
||||
|
@ -1563,6 +1575,10 @@ RSpec.describe Ticket, type: :model do
|
|||
template: 'ticket_update',
|
||||
user: user_no_mentions,
|
||||
)
|
||||
sent(
|
||||
template: 'ticket_update',
|
||||
user: user_read_mentions,
|
||||
)
|
||||
sent(
|
||||
template: 'ticket_update',
|
||||
user: user_only_mentions,
|
||||
|
@ -1583,6 +1599,10 @@ RSpec.describe Ticket, type: :model do
|
|||
template: 'ticket_update',
|
||||
user: user_no_mentions,
|
||||
)
|
||||
not_sent(
|
||||
template: 'ticket_update',
|
||||
user: user_read_mentions,
|
||||
)
|
||||
not_sent(
|
||||
template: 'ticket_update',
|
||||
user: user_only_mentions,
|
||||
|
@ -1593,6 +1613,7 @@ RSpec.describe Ticket, type: :model do
|
|||
it 'does inform mention user about ticket creation' do
|
||||
check_notification do
|
||||
ticket = create(:ticket, owner: user_no_mentions, group: mention_group)
|
||||
create(:mention, mentionable: ticket, user: user_read_mentions)
|
||||
create(:mention, mentionable: ticket, user: user_only_mentions)
|
||||
Observer::Transaction.commit
|
||||
Scheduler.worker(true)
|
||||
|
@ -1600,6 +1621,10 @@ RSpec.describe Ticket, type: :model do
|
|||
template: 'ticket_create',
|
||||
user: user_no_mentions,
|
||||
)
|
||||
sent(
|
||||
template: 'ticket_create',
|
||||
user: user_read_mentions,
|
||||
)
|
||||
sent(
|
||||
template: 'ticket_create',
|
||||
user: user_only_mentions,
|
||||
|
@ -1616,6 +1641,10 @@ RSpec.describe Ticket, type: :model do
|
|||
template: 'ticket_create',
|
||||
user: user_no_mentions,
|
||||
)
|
||||
not_sent(
|
||||
template: 'ticket_create',
|
||||
user: user_read_mentions,
|
||||
)
|
||||
not_sent(
|
||||
template: 'ticket_create',
|
||||
user: user_only_mentions,
|
||||
|
@ -1626,9 +1655,14 @@ RSpec.describe Ticket, type: :model do
|
|||
it 'does not inform mention user about ticket creation because of no permissions' do
|
||||
check_notification do
|
||||
ticket = create(:ticket, group: no_access_group)
|
||||
create(:mention, mentionable: ticket, user: user_read_mentions)
|
||||
create(:mention, mentionable: ticket, user: user_only_mentions)
|
||||
Observer::Transaction.commit
|
||||
Scheduler.worker(true)
|
||||
not_sent(
|
||||
template: 'ticket_create',
|
||||
user: user_read_mentions,
|
||||
)
|
||||
not_sent(
|
||||
template: 'ticket_create',
|
||||
user: user_only_mentions,
|
||||
|
|
Loading…
Reference in a new issue