fix: Email notifications (#8502)

This commit is contained in:
Muhsin Keloth
2023-12-06 15:50:23 +05:30
committed by GitHub
parent db33b7d1dc
commit 6b0d1d77d3
3 changed files with 10 additions and 10 deletions

View File

@@ -19,36 +19,36 @@ class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
send_mail_with_liquid(to: @agent.email, subject: subject) and return
end
def conversation_mention(message, agent)
def conversation_mention(conversation, agent, message)
return unless smtp_config_set_or_development?
@agent = agent
@conversation = message.conversation
@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(message, agent)
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 = message.conversation
@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(message, agent)
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 = message.conversation
@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

View File

@@ -9,7 +9,7 @@ class Notification::EmailNotificationService
# TODO : Clean up whatever happening over here
# Segregate the mailers properly
AgentNotifications::ConversationNotificationsMailer.with(account: notification.account).public_send(notification
.notification_type.to_s, notification.primary_actor, notification.user).deliver_now
.notification_type.to_s, notification.primary_actor, notification.user, notification.secondary_actor).deliver_later
end
private