chore: Change primary actor to Conversation for all the notification types. (#8435)
This commit is contained in:
parent
17faa6c3b2
commit
76711d95ff
@ -1,5 +1,5 @@
|
|||||||
class NotificationBuilder
|
class NotificationBuilder
|
||||||
pattr_initialize [:notification_type!, :user!, :account!, :primary_actor!]
|
pattr_initialize [:notification_type!, :user!, :account!, :primary_actor!, :secondary_actor]
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
return unless user_subscribed_to_notification?
|
return unless user_subscribed_to_notification?
|
||||||
@ -9,7 +9,7 @@ class NotificationBuilder
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def secondary_actor
|
def current_user
|
||||||
Current.user
|
Current.user
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,8 @@ class NotificationBuilder
|
|||||||
notification_type: notification_type,
|
notification_type: notification_type,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: primary_actor,
|
primary_actor: primary_actor,
|
||||||
secondary_actor: secondary_actor
|
# secondary_actor is secondary_actor if present, else current_user
|
||||||
|
secondary_actor: secondary_actor || current_user
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
8
app/jobs/migration/remove_message_notifications.rb
Normal file
8
app/jobs/migration/remove_message_notifications.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Delete migration and spec after 2 consecutive releases.
|
||||||
|
class Migration::RemoveMessageNotifications < ApplicationJob
|
||||||
|
queue_as :scheduled_jobs
|
||||||
|
|
||||||
|
def perform
|
||||||
|
Notification.where(primary_actor_type: 'Message').in_batches(of: 100).each_record(&:destroy)
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -68,17 +68,10 @@ class Notification < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def primary_actor_data
|
def primary_actor_data
|
||||||
if %w[assigned_conversation_new_message conversation_mention].include? notification_type
|
{
|
||||||
{
|
id: primary_actor.push_event_data[:id],
|
||||||
id: primary_actor.conversation.push_event_data[:id],
|
meta: primary_actor.push_event_data[:meta]
|
||||||
meta: primary_actor.conversation.push_event_data[:meta]
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id: primary_actor.push_event_data[:id],
|
|
||||||
meta: primary_actor.push_event_data[:meta]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fcm_push_data
|
def fcm_push_data
|
||||||
@ -92,37 +85,33 @@ class Notification < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
# TODO: move to a data presenter
|
# TODO: move to a data presenter
|
||||||
# rubocop:disable Metrics/CyclomaticComplexity
|
|
||||||
def push_message_title
|
def push_message_title
|
||||||
case notification_type
|
case notification_type
|
||||||
when 'conversation_creation'
|
when 'conversation_creation'
|
||||||
I18n.t('notifications.notification_title.conversation_creation', display_id: primary_actor.display_id, inbox_name: primary_actor.inbox.name)
|
I18n.t('notifications.notification_title.conversation_creation', display_id: conversation.display_id, inbox_name: primary_actor.inbox.name)
|
||||||
when 'conversation_assignment'
|
when 'conversation_assignment'
|
||||||
I18n.t('notifications.notification_title.conversation_assignment', display_id: primary_actor.display_id)
|
I18n.t('notifications.notification_title.conversation_assignment', display_id: conversation.display_id)
|
||||||
when 'assigned_conversation_new_message', 'participating_conversation_new_message'
|
when 'assigned_conversation_new_message', 'participating_conversation_new_message'
|
||||||
I18n.t(
|
I18n.t(
|
||||||
'notifications.notification_title.assigned_conversation_new_message',
|
'notifications.notification_title.assigned_conversation_new_message',
|
||||||
display_id: conversation.display_id,
|
display_id: conversation.display_id,
|
||||||
content: transform_user_mention_content(primary_actor&.content&.truncate_words(10))
|
content: content
|
||||||
)
|
)
|
||||||
when 'conversation_mention'
|
when 'conversation_mention'
|
||||||
"[##{conversation&.display_id}] #{transform_user_mention_content primary_actor&.content}"
|
"[##{conversation&.display_id}] #{transform_user_mention_content content}"
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/CyclomaticComplexity
|
|
||||||
|
|
||||||
def conversation
|
def conversation
|
||||||
return primary_actor.conversation if %w[
|
|
||||||
assigned_conversation_new_message
|
|
||||||
participating_conversation_new_message
|
|
||||||
conversation_mention
|
|
||||||
].include? notification_type
|
|
||||||
|
|
||||||
primary_actor
|
primary_actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def content
|
||||||
|
transform_user_mention_content(secondary_actor&.content&.truncate_words(10) || '')
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def process_notification_delivery
|
def process_notification_delivery
|
||||||
|
|||||||
@ -35,7 +35,8 @@ class Messages::MentionService
|
|||||||
notification_type: 'conversation_mention',
|
notification_type: 'conversation_mention',
|
||||||
user: User.find(user_id),
|
user: User.find(user_id),
|
||||||
account: message.account,
|
account: message.account,
|
||||||
primary_actor: message
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message
|
||||||
).perform
|
).perform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,8 @@ class Messages::NewMessageNotificationService
|
|||||||
notification_type: 'participating_conversation_new_message',
|
notification_type: 'participating_conversation_new_message',
|
||||||
user: participant,
|
user: participant,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message
|
||||||
).perform
|
).perform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -35,7 +36,8 @@ class Messages::NewMessageNotificationService
|
|||||||
notification_type: 'assigned_conversation_new_message',
|
notification_type: 'assigned_conversation_new_message',
|
||||||
user: conversation.assignee,
|
user: conversation.assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message
|
||||||
).perform
|
).perform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -11,19 +11,9 @@ json.data do
|
|||||||
json.notification_type notification.notification_type
|
json.notification_type notification.notification_type
|
||||||
json.push_message_title notification.push_message_title
|
json.push_message_title notification.push_message_title
|
||||||
# TODO: front end assumes primary actor to be conversation. should fix in future
|
# TODO: front end assumes primary actor to be conversation. should fix in future
|
||||||
if %w[
|
json.primary_actor_type notification.primary_actor_type
|
||||||
assigned_conversation_new_message
|
json.primary_actor_id notification.primary_actor_id
|
||||||
participating_conversation_new_message
|
json.primary_actor notification.primary_actor.push_event_data
|
||||||
conversation_mention
|
|
||||||
].include? notification.notification_type
|
|
||||||
json.primary_actor_type 'Conversation'
|
|
||||||
json.primary_actor_id notification.conversation.id
|
|
||||||
json.primary_actor notification.conversation.push_event_data
|
|
||||||
else
|
|
||||||
json.primary_actor_type notification.primary_actor_type
|
|
||||||
json.primary_actor_id notification.primary_actor_id
|
|
||||||
json.primary_actor notification.primary_actor.push_event_data
|
|
||||||
end
|
|
||||||
json.read_at notification.read_at
|
json.read_at notification.read_at
|
||||||
# Secondary actor could be nil for cases like system assigning conversation
|
# Secondary actor could be nil for cases like system assigning conversation
|
||||||
json.secondary_actor notification.secondary_actor&.push_event_data
|
json.secondary_actor notification.secondary_actor&.push_event_data
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
class RemoveNotificationsWithMessagePrimaryActor < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
Migration::RemoveMessageNotifications.perform_later
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2023_11_29_091149) do
|
ActiveRecord::Schema[7.0].define(version: 2023_12_01_014644) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
enable_extension "pg_trgm"
|
enable_extension "pg_trgm"
|
||||||
|
|||||||
10
spec/jobs/migration/remove_message_notifications_spec.rb
Normal file
10
spec/jobs/migration/remove_message_notifications_spec.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Migration::RemoveMessageNotifications do
|
||||||
|
subject(:job) { described_class.perform_later }
|
||||||
|
|
||||||
|
it 'enqueues the job' do
|
||||||
|
expect { job }.to have_enqueued_job(described_class)
|
||||||
|
.on_queue('scheduled_jobs')
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -24,7 +24,6 @@ RSpec.describe Notification do
|
|||||||
context 'when push_title is called' do
|
context 'when push_title is called' do
|
||||||
it 'returns appropriate title suited for the notification type conversation_creation' do
|
it 'returns appropriate title suited for the notification type conversation_creation' do
|
||||||
notification = create(:notification, notification_type: 'conversation_creation')
|
notification = create(:notification, notification_type: 'conversation_creation')
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New conversation] - ##{notification.primary_actor.display_id} has\
|
expect(notification.push_message_title).to eq "[New conversation] - ##{notification.primary_actor.display_id} has\
|
||||||
been created in #{notification.primary_actor.inbox.name}"
|
been created in #{notification.primary_actor.inbox.name}"
|
||||||
end
|
end
|
||||||
@ -37,7 +36,8 @@ RSpec.describe Notification do
|
|||||||
|
|
||||||
it 'returns appropriate title suited for the notification type assigned_conversation_new_message' do
|
it 'returns appropriate title suited for the notification type assigned_conversation_new_message' do
|
||||||
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
||||||
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message)
|
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
||||||
#{message.content.truncate_words(10)}"
|
#{message.content.truncate_words(10)}"
|
||||||
@ -46,14 +46,16 @@ RSpec.describe Notification do
|
|||||||
it 'returns appropriate title suited for the notification type assigned_conversation_new_message when attachment message' do
|
it 'returns appropriate title suited for the notification type assigned_conversation_new_message when attachment message' do
|
||||||
# checking content nil should be suffice for attachments
|
# checking content nil should be suffice for attachments
|
||||||
message = create(:message, sender: create(:user), content: nil)
|
message = create(:message, sender: create(:user), content: nil)
|
||||||
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message)
|
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} "
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} "
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns appropriate title suited for the notification type participating_conversation_new_message' do
|
it 'returns appropriate title suited for the notification type participating_conversation_new_message' do
|
||||||
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
||||||
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message)
|
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
||||||
#{message.content.truncate_words(10)}"
|
#{message.content.truncate_words(10)}"
|
||||||
@ -61,17 +63,16 @@ RSpec.describe Notification do
|
|||||||
|
|
||||||
it 'returns appropriate title suited for the notification type participating_conversation_new_message having mention' do
|
it 'returns appropriate title suited for the notification type participating_conversation_new_message having mention' do
|
||||||
message = create(:message, sender: create(:user), content: 'Hey [@John](mention://user/1/john), can you check this ticket?')
|
message = create(:message, sender: create(:user), content: 'Hey [@John](mention://user/1/john), can you check this ticket?')
|
||||||
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message,
|
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message.conversation,
|
||||||
secondary_actor: message.sender)
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} Hey @John, can you check this ticket?"
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} Hey @John, can you check this ticket?"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns appropriate title suited for the notification type participating_conversation_new_message having multple mention' do
|
it 'returns appropriate title suited for the notification type participating_conversation_new_message having multple mention' do
|
||||||
message = create(:message, sender: create(:user),
|
message = create(:message, sender: create(:user),
|
||||||
content: 'Hey [@John](mention://user/1/john), [@Alisha Peter](mention://user/2/alisha) can you check this ticket?')
|
content: 'Hey [@John](mention://user/1/john), [@Alisha Peter](mention://user/2/alisha) can you check this ticket?')
|
||||||
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message,
|
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message.conversation,
|
||||||
secondary_actor: message.sender)
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
||||||
Hey @John, @Alisha Peter can you check this ticket?"
|
Hey @John, @Alisha Peter can you check this ticket?"
|
||||||
@ -79,15 +80,15 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
|||||||
|
|
||||||
it 'returns appropriate title suited for the notification type participating_conversation_new_message if username contains white space' do
|
it 'returns appropriate title suited for the notification type participating_conversation_new_message if username contains white space' do
|
||||||
message = create(:message, sender: create(:user), content: 'Hey [@John Peter](mention://user/1/john%20K) please check this?')
|
message = create(:message, sender: create(:user), content: 'Hey [@John Peter](mention://user/1/john%20K) please check this?')
|
||||||
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message,
|
notification = create(:notification, notification_type: 'participating_conversation_new_message', primary_actor: message.conversation,
|
||||||
secondary_actor: message.sender)
|
secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} Hey @John Peter please check this?"
|
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} Hey @John Peter please check this?"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns appropriate title suited for the notification type conversation_mention' do
|
it 'returns appropriate title suited for the notification type conversation_mention' do
|
||||||
message = create(:message, sender: create(:user), content: 'Hey [@John](mention://user/1/john), can you check this ticket?')
|
message = create(:message, sender: create(:user), content: 'Hey [@John](mention://user/1/john), can you check this ticket?')
|
||||||
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message, secondary_actor: message.sender)
|
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message.conversation, secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John, can you check this ticket?"
|
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John, can you check this ticket?"
|
||||||
end
|
end
|
||||||
@ -98,7 +99,7 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
|||||||
create(:user),
|
create(:user),
|
||||||
content: 'Hey [@John](mention://user/1/john), [@Alisha Peter](mention://user/2/alisha) can you check this ticket?'
|
content: 'Hey [@John](mention://user/1/john), [@Alisha Peter](mention://user/2/alisha) can you check this ticket?'
|
||||||
)
|
)
|
||||||
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message, secondary_actor: message.sender)
|
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message.conversation, secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John, @Alisha Peter can you check this ticket?"
|
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John, @Alisha Peter can you check this ticket?"
|
||||||
end
|
end
|
||||||
@ -109,8 +110,7 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
|||||||
create(:user),
|
create(:user),
|
||||||
content: 'Hey [@John Peter](mention://user/1/john%20K) please check this?'
|
content: 'Hey [@John Peter](mention://user/1/john%20K) please check this?'
|
||||||
)
|
)
|
||||||
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message, secondary_actor: message.sender)
|
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message.conversation, secondary_actor: message)
|
||||||
|
|
||||||
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John Peter please check this?"
|
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John Peter please check this?"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -125,11 +125,10 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
|||||||
|
|
||||||
it 'returns correct data for primary actor message' do
|
it 'returns correct data for primary actor message' do
|
||||||
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2))
|
||||||
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message)
|
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
expect(notification.fcm_push_data[:primary_actor]).to eq({
|
expect(notification.fcm_push_data[:primary_actor]).to eq({
|
||||||
'id' => notification.primary_actor.id,
|
'id' => notification.primary_actor.display_id
|
||||||
'conversation_id' => notification.primary_actor.conversation.display_id
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -32,7 +32,8 @@ describe Messages::MentionService do
|
|||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
||||||
user: first_agent,
|
user: first_agent,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,11 +56,13 @@ describe Messages::MentionService do
|
|||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
||||||
user: second_agent,
|
user: second_agent,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
||||||
user: first_agent,
|
user: first_agent,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'add the users to the participants list' do
|
it 'add the users to the participants list' do
|
||||||
|
|||||||
@ -40,21 +40,24 @@ describe Messages::NewMessageNotificationService do
|
|||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
||||||
user: participating_agent_2,
|
user: participating_agent_2,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates notifications for assignee' do
|
it 'creates notifications for assignee' do
|
||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
||||||
user: assignee,
|
user: assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'will not create notifications for the user who created the message' do
|
it 'will not create notifications for the user who created the message' do
|
||||||
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
||||||
user: participating_agent_1,
|
user: participating_agent_1,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,18 +72,21 @@ describe Messages::NewMessageNotificationService do
|
|||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
||||||
user: assignee,
|
user: assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates notifications for all participating users' do
|
it 'creates notifications for all participating users' do
|
||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
||||||
user: participating_agent_1,
|
user: participating_agent_1,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
||||||
user: participating_agent_2,
|
user: participating_agent_2,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,7 +103,8 @@ describe Messages::NewMessageNotificationService do
|
|||||||
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
||||||
user: assignee,
|
user: assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -112,11 +119,13 @@ describe Messages::NewMessageNotificationService do
|
|||||||
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'participating_conversation_new_message',
|
||||||
user: assignee,
|
user: assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
expect(NotificationBuilder).not_to have_received(:new).with(notification_type: 'assigned_conversation_new_message',
|
||||||
user: assignee,
|
user: assignee,
|
||||||
account: account,
|
account: account,
|
||||||
primary_actor: message)
|
primary_actor: message.conversation,
|
||||||
|
secondary_actor: message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user