Feature: Conversation creation email notifications (#576)

* Clean up the mailers

* Disable assignment mailer if setting is turned off

* Email notifications on conversation create

* Specs
This commit is contained in:
Sojan Jose
2020-03-01 19:06:13 +05:30
committed by GitHub
parent d6237dfc59
commit cda65ea339
17 changed files with 160 additions and 31 deletions

View File

@@ -0,0 +1,21 @@
class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com')
layout 'mailer'
def conversation_created(conversation, agent)
return unless smtp_config_set_or_development?
@agent = agent
@conversation = conversation
subject = "#{@agent.name}, A new conversation [ID - #{@conversation.display_id}] has been created in #{@conversation.inbox&.name}."
mail(to: @agent.email, subject: subject)
end
def conversation_assigned(conversation, agent)
return unless smtp_config_set_or_development?
@agent = agent
@conversation = conversation
mail(to: @agent.email, subject: "#{@agent.name}, A new conversation [ID - #{@conversation.display_id}] has been assigned to you.")
end
end

View File

@@ -1,6 +1,7 @@
class ApplicationMailer < ActionMailer::Base
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com')
layout 'mailer'
append_view_path Rails.root.join('app/views/mailers')
# helpers
helper :frontend_urls

View File

@@ -1,12 +0,0 @@
class AssignmentMailer < ApplicationMailer
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com')
layout 'mailer'
def conversation_assigned(conversation, agent)
return unless smtp_config_set_or_development?
@agent = agent
@conversation = conversation
mail(to: @agent.email, subject: "#{@agent.name}, A new conversation [ID - #{@conversation.display_id}] has been assigned to you.")
end
end

View File

@@ -1,8 +1,8 @@
class ConversationMailer < ApplicationMailer
class ConversationReplyMailer < ApplicationMailer
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'accounts@chatwoot.com')
layout 'mailer'
def new_message(conversation, message_queued_time)
def reply_with_summary(conversation, message_queued_time)
return unless smtp_config_set_or_development?
@conversation = conversation