diff --git a/app/mailers/conversation_reply_mailer.rb b/app/mailers/conversation_reply_mailer.rb index a82c65440..8dbe67bf8 100644 --- a/app/mailers/conversation_reply_mailer.rb +++ b/app/mailers/conversation_reply_mailer.rb @@ -39,8 +39,7 @@ class ConversationReplyMailer < ApplicationMailer init_conversation_attributes(message.conversation) @message = message - reply_mail_object = prepare_mail(true) - message.update(source_id: reply_mail_object.message_id) + prepare_mail(true) end def conversation_transcript(conversation, to_email) diff --git a/app/services/email/send_on_email_service.rb b/app/services/email/send_on_email_service.rb index b859e71ae..db9f9aa69 100644 --- a/app/services/email/send_on_email_service.rb +++ b/app/services/email/send_on_email_service.rb @@ -8,7 +8,10 @@ class Email::SendOnEmailService < Base::SendOnChannelService def perform_reply return unless message.email_notifiable_message? - ConversationReplyMailer.with(account: message.account).email_reply(message).deliver_now + reply_mail = ConversationReplyMailer.with(account: message.account).email_reply(message) + reply_mail.deliver_now + Rails.logger.info("Email message #{message.id} send with source_id: #{reply_mail.message_id}") + message.update(source_id: reply_mail.message_id) rescue StandardError => e ChatwootExceptionTracker.new(e, account: message.account).capture_exception Messages::StatusUpdateService.new(message, 'failed', e.message).perform