* feat(mailer): add i18n support for all transactional emails with pt-BR translations - Create Liquid i18n filter (LiquidFilters::I18nFilter) exposing I18n.t() as `t` filter with interpolation support via positional args - Replace hardcoded English strings in all 26 Liquid email templates with i18n keys - Replace hardcoded English strings in all 5 Devise ERB email templates (OSS + enterprise) with t() calls, using raw output (<%==) to prevent HTML-encoding of apostrophes - Translate all mailer subjects to use I18n.t() for locale-aware rendering - Add comprehensive pt-BR translations for all transactional emails - Add SSO-specific i18n keys for enterprise confirmation instructions - Fix ApplicationRecord#to_drop to walk STI hierarchy (e.g. SuperAdmin -> UserDrop) * fix: address CodeRabbit review feedback - Use _html suffix for Devise translation keys to prevent XSS while keeping apostrophes unencoded (Rails escapes interpolations automatically) - Replace hardcoded English in SLA templates with full_body i18n keys - Fix _target="blank" typo to target="_blank" in attachment links - Add i18n for tiktok_disconnect subject and create liquid template - Extract brand_name to private method in AccountNotificationMailer * fix: address round 2 review feedback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
3.5 KiB
Ruby
76 lines
3.5 KiB
Ruby
class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
|
|
def conversation_creation(conversation, agent, _user)
|
|
return unless smtp_config_set_or_development?
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
inbox_name = @conversation.inbox&.sanitized_name
|
|
subject = I18n.t('mailer.agent_notifications.conversation_creation.subject',
|
|
agent_name: @agent.available_name, conversation_id: @conversation.display_id, inbox_name: inbox_name)
|
|
@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
|
|
end
|
|
|
|
def conversation_assignment(conversation, agent, _user)
|
|
return unless smtp_config_set_or_development?
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
subject = I18n.t('mailer.agent_notifications.conversation_assignment.subject',
|
|
agent_name: @agent.available_name, conversation_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
|
|
end
|
|
|
|
def conversation_mention(conversation, agent, message)
|
|
return unless smtp_config_set_or_development?
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
@message = message
|
|
subject = I18n.t('mailer.agent_notifications.conversation_mention.subject',
|
|
agent_name: @agent.available_name, conversation_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
|
|
end
|
|
|
|
def assigned_conversation_new_message(conversation, agent, message)
|
|
return unless smtp_config_set_or_development?
|
|
# Don't spam with email notifications if agent is online
|
|
return if ::OnlineStatusTracker.get_presence(message.account_id, 'User', agent.id)
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
subject = I18n.t('mailer.agent_notifications.assigned_conversation_new_message.subject',
|
|
agent_name: @agent.available_name, conversation_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
|
|
end
|
|
|
|
def participating_conversation_new_message(conversation, agent, message)
|
|
return unless smtp_config_set_or_development?
|
|
# Don't spam with email notifications if agent is online
|
|
return if ::OnlineStatusTracker.get_presence(message.account_id, 'User', agent.id)
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
subject = I18n.t('mailer.agent_notifications.participating_conversation_new_message.subject',
|
|
agent_name: @agent.available_name, conversation_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
|
|
end
|
|
|
|
private
|
|
|
|
def liquid_droppables
|
|
super.merge({
|
|
user: @agent,
|
|
conversation: @conversation,
|
|
inbox: @conversation.inbox,
|
|
message: @message
|
|
})
|
|
end
|
|
end
|
|
|
|
AgentNotifications::ConversationNotificationsMailer.prepend_mod_with('AgentNotifications::ConversationNotificationsMailer')
|