feat: Notification on new messages in conversation (#1204)
fixes: #895 fixes: #1118 fixes: #1075 Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
@@ -36,4 +36,21 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
||||
expect(mail.to).to eq([agent.email])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'assigned_conversation_new_message' do
|
||||
let(:mail) { described_class.assigned_conversation_new_message(conversation, agent).deliver_now }
|
||||
|
||||
it 'renders the subject' do
|
||||
expect(mail.subject).to eq("#{agent.available_name}, New message in your assigned conversation [ID - #{conversation.display_id}].")
|
||||
end
|
||||
|
||||
it 'renders the receiver email' do
|
||||
expect(mail.to).to eq([agent.email])
|
||||
end
|
||||
|
||||
it 'will not send email if agent is online' do
|
||||
::OnlineStatusTracker.update_presence(conversation.account.id, 'User', agent.id)
|
||||
expect(mail).to eq nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,9 +14,9 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
||||
end
|
||||
|
||||
context 'with summary' do
|
||||
let(:conversation) { create(:conversation, assignee: agent) }
|
||||
let(:message) { create(:message, conversation: conversation) }
|
||||
let(:private_message) { create(:message, content: 'This is a private message', conversation: conversation) }
|
||||
let(:conversation) { create(:conversation, account: account, assignee: agent) }
|
||||
let(:message) { create(:message, account: account, conversation: conversation) }
|
||||
let(:private_message) { create(:message, account: account, content: 'This is a private message', conversation: conversation) }
|
||||
let(:mail) { described_class.reply_with_summary(message.conversation, Time.zone.now).deliver_now }
|
||||
|
||||
it 'renders the subject' do
|
||||
@@ -31,6 +31,12 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
||||
expect(mail.body.decoded).not_to include(private_message.content)
|
||||
expect(mail.body.decoded).to include(message.content)
|
||||
end
|
||||
|
||||
it 'will not send email if conversation is already viewed by contact' do
|
||||
create(:message, message_type: 'outgoing', account: account, conversation: conversation)
|
||||
conversation.update(contact_last_seen_at: Time.zone.now)
|
||||
expect(mail).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'without assignee' do
|
||||
@@ -75,6 +81,12 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
||||
expect(mail.body.decoded).not_to include(message_1.content)
|
||||
expect(mail.body.decoded).to include(message_2.content)
|
||||
end
|
||||
|
||||
it 'will not send email if conversation is already viewed by contact' do
|
||||
create(:message, message_type: 'outgoing', account: account, conversation: conversation)
|
||||
conversation.update(contact_last_seen_at: Time.zone.now)
|
||||
expect(mail).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when custom domain and email is not enabled' do
|
||||
|
||||
Reference in New Issue
Block a user