chore: Enable additional attributes in liquid (#1144)
enable additional liquid variables in mailers Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
parent
0117997fb1
commit
be91b322a4
4 changed files with 18 additions and 11 deletions
|
@ -1,2 +1,5 @@
|
|||
class UserDrop < BaseDrop
|
||||
def available_name
|
||||
@obj.try(:available_name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,10 @@ class ApplicationMailer < ActionMailer::Base
|
|||
# Merge additional objects into this in your mailer
|
||||
# liquid template handler converts these objects into drop objects
|
||||
{
|
||||
account: Current.account
|
||||
account: Current.account,
|
||||
user: @agent,
|
||||
conversation: @conversation,
|
||||
inbox: @conversation&.inbox
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -5,10 +5,7 @@ class ConversationReplyMailer < ApplicationMailer
|
|||
def reply_with_summary(conversation, message_queued_time)
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
@conversation = conversation
|
||||
@account = @conversation.account
|
||||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
init_conversation_attributes(conversation)
|
||||
|
||||
recap_messages = @conversation.messages.chat.where('created_at < ?', message_queued_time).last(10)
|
||||
new_messages = @conversation.messages.chat.where('created_at >= ?', message_queued_time)
|
||||
|
@ -29,10 +26,7 @@ class ConversationReplyMailer < ApplicationMailer
|
|||
def reply_without_summary(conversation, message_queued_time)
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
@conversation = conversation
|
||||
@account = @conversation.account
|
||||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
init_conversation_attributes(conversation)
|
||||
|
||||
@messages = @conversation.messages.chat.outgoing.where('created_at >= ?', message_queued_time)
|
||||
return false if @messages.count.zero?
|
||||
|
@ -49,6 +43,13 @@ class ConversationReplyMailer < ApplicationMailer
|
|||
|
||||
private
|
||||
|
||||
def init_conversation_attributes(conversation)
|
||||
@conversation = conversation
|
||||
@account = @conversation.account
|
||||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
end
|
||||
|
||||
def assignee_name
|
||||
@assignee_name ||= @agent&.available_name || 'Notifications'
|
||||
end
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<div class="footer" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
|
||||
<table width="100%" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
||||
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
||||
{% if global_config['BRAND_NAME'] %}
|
||||
{% if global_config['BRAND_NAME'] != '' %}
|
||||
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
||||
<td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
|
||||
Powered by
|
||||
|
@ -109,4 +109,4 @@
|
|||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue