Chore: Parse quoted text in incoming emails (#883) (#884)

* Chore: Parse quoted text in incoming emails (#883)
* Parsed the quoted text and replies in incoming emails and store them separately
* Did this parsing for plain text and html part of emails
* In the chat window, we will only show the parsed reply alone

* Conversation mailbox test fixes (#883)
This commit is contained in:
Sony Mathew
2020-05-22 18:07:06 +05:30
committed by GitHub
parent 00093fa408
commit 11b4b4ea3f
4 changed files with 59 additions and 13 deletions

View File

@@ -8,7 +8,7 @@ RSpec.describe ConversationMailbox, type: :mailbox do
let(:reply_mail) { create_inbound_email_from_fixture('reply.eml') }
let(:conversation) { create(:conversation, assignee: agent) }
let(:described_subject) { described_class.receive reply_mail }
let(:serialized_attributes) { %w[content number_of_attachments subject date to from in_reply_to cc bcc message_id] }
let(:serialized_attributes) { %w[text_content html_content number_of_attachments subject date to from in_reply_to cc bcc message_id] }
before do
# this UUID is hardcoded in the reply.eml, that's why we are updating this
@@ -19,7 +19,7 @@ RSpec.describe ConversationMailbox, type: :mailbox do
end
it 'add the mail content as new message on the conversation' do
expect(conversation.messages.last.content).to eq("Let's talk about these images:\r\n\r\n")
expect(conversation.messages.last.content).to eq("Let's talk about these images:")
end
it 'add the attachments' do

View File

@@ -8,7 +8,7 @@ RSpec.describe MailPresenter do
it 'give utf8 encoded content' do
expect(decorated_mail.subject).to eq("Discussion: Let's debate these attachments")
expect(decorated_mail.content).to eq("Let's talk about these images:\r\n\r\n")
expect(decorated_mail.text_content[:full]).to eq("Let's talk about these images:\r\n\r\n")
end
it 'give decoded blob attachments' do
@@ -24,7 +24,10 @@ RSpec.describe MailPresenter do
it 'give the serialized data of the email to be stored in the message' do
data = decorated_mail.serialized_data
expect(data.keys).to eq([:content, :number_of_attachments, :subject, :date, :to, :from, :in_reply_to, :cc, :bcc, :message_id])
expect(data.keys).to eq([
:text_content, :html_content, :number_of_attachments, :subject, :date, :to,
:from, :in_reply_to, :cc, :bcc, :message_id
])
expect(data[:subject]).to eq(decorated_mail.subject)
expect(data[:date].to_s).to eq('2020-04-20T04:20:20-04:00')
expect(data[:message_id]).to eq(mail.message_id)