feat: Add message content to mention email template (#2838)
This commit is contained in:
parent
20b96c7c60
commit
eb80324eaa
5 changed files with 37 additions and 8 deletions
12
app/drops/message_drop.rb
Normal file
12
app/drops/message_drop.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class MessageDrop < BaseDrop
|
||||||
|
include MessageFormatHelper
|
||||||
|
|
||||||
|
def sender_display_name
|
||||||
|
@obj.sender.try(:display_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def text_content
|
||||||
|
content = @obj.try(:content)
|
||||||
|
transform_user_mention_content content
|
||||||
|
end
|
||||||
|
end
|
|
@ -24,6 +24,7 @@ class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
|
||||||
|
|
||||||
@agent = agent
|
@agent = agent
|
||||||
@conversation = message.conversation
|
@conversation = message.conversation
|
||||||
|
@message = message
|
||||||
subject = "#{@agent.available_name}, You have been mentioned in conversation [ID - #{@conversation.display_id}]"
|
subject = "#{@agent.available_name}, You have been mentioned in conversation [ID - #{@conversation.display_id}]"
|
||||||
@action_url = app_account_conversation_url(account_id: @conversation.account_id, id: @conversation.display_id)
|
@action_url = app_account_conversation_url(account_id: @conversation.account_id, id: @conversation.display_id)
|
||||||
send_mail_with_liquid(to: @agent.email, subject: subject) and return
|
send_mail_with_liquid(to: @agent.email, subject: subject) and return
|
||||||
|
@ -47,7 +48,8 @@ class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
|
||||||
super.merge({
|
super.merge({
|
||||||
user: @agent,
|
user: @agent,
|
||||||
conversation: @conversation,
|
conversation: @conversation,
|
||||||
inbox: @conversation.inbox
|
inbox: @conversation.inbox,
|
||||||
|
message: @message
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||||
self.abstract_class = true
|
self.abstract_class = true
|
||||||
|
|
||||||
# the models that exposed in email templates through liquid
|
# the models that exposed in email templates through liquid
|
||||||
DROPPABLES = %w[Account Channel Conversation Inbox User].freeze
|
DROPPABLES = %w[Account Channel Conversation Inbox User Message].freeze
|
||||||
|
|
||||||
# ModelDrop class should exist in app/drops
|
# ModelDrop class should exist in app/drops
|
||||||
def to_drop
|
def to_drop
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<p>Hi {{user.available_name}}</p>
|
<style type="text/css">
|
||||||
|
.quoted-text--content {
|
||||||
|
box-sizing:border-box;
|
||||||
|
padding:8px 16px;
|
||||||
|
margin:0 0 20px;
|
||||||
|
font-size:14px;
|
||||||
|
border-left:5px solid #eeeeee
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<p>Hi {{user.available_name}}, </p>
|
||||||
|
|
||||||
<p>Time to save the world. You have been mentioned in a conversation</p>
|
<p>You've been mentioned in a conversation. <b>{{message.sender_display_name}}</b> wrote:</p>
|
||||||
|
<blockquote class='quoted-text--content'>
|
||||||
|
{{message.text_content}}
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p><a href="{{ action_url }}">View Message</a></p>
|
||||||
Click <a href="{{ action_url }}">here</a> to get cracking.
|
|
||||||
</p>
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'conversation_mention' do
|
describe 'conversation_mention' do
|
||||||
let(:message) { create(:message, conversation: conversation, account: account) }
|
let(:another_agent) { create(:user, email: 'agent2@example.com', account: account) }
|
||||||
|
let(:message) { create(:message, conversation: conversation, account: account, sender: another_agent) }
|
||||||
let(:mail) { described_class.with(account: account).conversation_mention(message, agent).deliver_now }
|
let(:mail) { described_class.with(account: account).conversation_mention(message, agent).deliver_now }
|
||||||
|
|
||||||
it 'renders the subject' do
|
it 'renders the subject' do
|
||||||
|
@ -49,6 +50,10 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
||||||
it 'renders the receiver email' do
|
it 'renders the receiver email' do
|
||||||
expect(mail.to).to eq([agent.email])
|
expect(mail.to).to eq([agent.email])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'renders the senders name' do
|
||||||
|
expect(mail.body.encoded).to match("You've been mentioned in a conversation. <b>#{another_agent.display_name}</b> wrote:")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'assigned_conversation_new_message' do
|
describe 'assigned_conversation_new_message' do
|
||||||
|
|
Loading…
Reference in a new issue