Feat: Include previous messages in mention/assign notifications email (#3385)

This commit is contained in:
Shivam Chahar
2021-11-17 18:05:53 +05:30
committed by GitHub
parent 9ea42ebff2
commit fec4a29081
5 changed files with 88 additions and 0 deletions

View File

@@ -1,5 +1,17 @@
class ConversationDrop < BaseDrop
include MessageFormatHelper
def display_id
@obj.try(:display_id)
end
def recent_messages
@obj.try(:recent_messages).map do |message|
{
'sender' => message.sender&.available_name || message.sender&.name,
'content' => transform_user_mention_content(message.content),
'attachments' => message.attachments.map(&:file_url)
}
end
end
end

View File

@@ -147,6 +147,10 @@ class Conversation < ApplicationRecord
inbox.inbox_type == 'Twitter' && additional_attributes['type'] == 'tweet'
end
def recent_messages
messages.chat.last(5)
end
private
def execute_after_update_commit_callbacks

View File

@@ -2,6 +2,30 @@
<p>Time to save the world. A new conversation has been assigned to you</p>
{% for chat_message in conversation.recent_messages %}
<div>
{% if chat_message.sender == user.available_name %}
<h4 style="margin: 0;">You</h4>
{% else %}
<h4 style="margin: 0;">{{chat_message.sender}}</h4>
{% endif %}
</div>
<div>
<p style="padding: 10px 20px; margin: 5px 0 20px 0; background: #F2F3F7; border-radius: 10px; display: inline-block; font-family: "Helvetica Neue",Tahoma,Arial,sans-serif; text-align: start; unicode-bidi: plaintext;">
{% if chat_message.content %}
{{chat_message.content}}
{% endif %}
{% if chat_message.attachments %}
{% for attachment in chat_message.attachments %}
Attachment [<a href="{{ attachment }}" _target="blank">Click here to view</a>]
{% endfor %}
{% endif %}
</p>
</div>
{% endfor %}
<p>
Click <a href="{{action_url}}">here</a> to get cracking.
</p>

View File

@@ -5,4 +5,28 @@
{{message.text_content}}
</blockquote>
{% for chat_message in conversation.recent_messages %}
<div>
{% if chat_message.sender == user.available_name %}
<h4 style="margin: 0;">You</h4>
{% else %}
<h4 style="margin: 0;">{{chat_message.sender}}</h4>
{% endif %}
</div>
<div>
<p style="padding: 10px 20px; margin: 5px 0 20px 0; background: #F2F3F7; border-radius: 10px; display: inline-block; font-family: "Helvetica Neue",Tahoma,Arial,sans-serif; text-align: start; unicode-bidi: plaintext;">
{% if chat_message.content %}
{{chat_message.content}}
{% endif %}
{% if chat_message.attachments %}
{% for attachment in chat_message.attachments %}
Attachment [<a href="{{ attachment }}" _target="blank">Click here to view</a>]
{% endfor %}
{% endif %}
</p>
</div>
{% endfor %}
<p><a href="{{ action_url }}">View Message</a></p>