* feat: update SLA evaluation logic * Update enterprise/app/services/sla/evaluate_applied_sla_service.rb Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> * chore: refactor spec to bring down expecations in a single block * chore: fix process_account_applied_sla spec * chore: add spec to test multiple nrt misses * feat: persist sla notifications * feat: revert persist sla notifications * feat: add SLA push/email notification support * chore: refactor sla_status to include active_with_misses * chore: add support for sla push/email notifications * chore: refactor * chore: add liquid templates * chore: add spec for liquid templates * chore: add spec for sla email notifications * chore: add spec for SlaPolicyDrop * chore: refactor to ee namespace * chore: set enterprise test type to mailer * feat: enable sla notification settings only if SLA enabled * chore: refactor * chore: fix spec --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
71 lines
3.2 KiB
Ruby
71 lines
3.2 KiB
Ruby
class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
|
|
def conversation_creation(conversation, agent, _user)
|
|
return unless smtp_config_set_or_development?
|
|
|
|
@agent = agent
|
|
@conversation = conversation
|
|
subject = "#{@agent.available_name}, A new conversation [ID - #{@conversation.display_id}] has been created in #{@conversation.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 = "#{@agent.available_name}, A new conversation [ID - #{@conversation.display_id}] has been assigned to you."
|
|
@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 = "#{@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)
|
|
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 = "#{@agent.available_name}, New message in your assigned 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 = "#{@agent.available_name}, New message in your participating 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,
|
|
sla_policy: @sla_policy
|
|
})
|
|
end
|
|
end
|
|
|
|
AgentNotifications::ConversationNotificationsMailer.include_mod_with('AgentNotifications::ConversationNotificationsMailer')
|