fix: Update mail check for html_part (#7273)

This commit is contained in:
Tejaswini Chile
2023-06-09 16:08:40 +05:30
committed by GitHub
parent 48f2e58e59
commit f64f2138db
4 changed files with 6011 additions and 5 deletions

View File

@@ -125,7 +125,7 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob
rescue StandardError => e
ChatwootExceptionTracker.new(e, account: channel.account).capture_exception
Rails.logger.error("
#{channel.provider} Email dropped: #{inbound_mail.from} and message_source_id: #{inbound_mail.message_id}, message_id: #{message_id}")
#{channel.provider} Email dropped: #{inbound_mail.from} and message_source_id: #{inbound_mail.message_id}")
end
# Making sure the access token is valid for microsoft provider

View File

@@ -38,11 +38,9 @@ module MailboxHelper
end
def embed_inline_image_source(mail_attachment)
current_mail = processed_mail.mail
if current_mail.html_part.present?
if processed_mail.serialized_data[:html_content].present?
upload_inline_image(mail_attachment)
elsif current_mail.text_part.present?
elsif processed_mail.serialized_data[:text_content].present?
embed_plain_text_email_with_inline_image(mail_attachment)
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -110,6 +110,29 @@ RSpec.describe ReplyMailbox do
end
end
context 'with inline attachments and html_part' do
let(:mail_with_html_part_no_html_content) { create_inbound_email_from_fixture('mail_with_html_part_no_html_content.eml') }
let(:described_subject) { described_class.receive mail_with_html_part_no_html_content }
before do
conversation.uuid = '6bdc3f4d-0bed-4515-a284-5d916fdde489'
conversation.save!
described_subject
end
it 'mail content will create message' do
expect(conversation.messages.last.content).to include('This is test message.')
end
it 'html_content is empty' do
expect(conversation.messages.last.attachments.count).to eq(0)
html_full_content = conversation.messages.last.content_attributes[:email][:html_content][:full]
expect(html_full_content).to be_nil
end
end
context 'with reply_to email address present' do
let(:email_channel) { create(:channel_email, email: 'test@example.com', account: account) }
let(:conversation_1) do