fix: Improve mail content parsing (#2638)
This commit is contained in:
parent
85ea56b765
commit
5aac2acf56
2 changed files with 15 additions and 5 deletions
|
@ -9,11 +9,13 @@ class SupportMailbox < ApplicationMailbox
|
||||||
:decorate_mail
|
:decorate_mail
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
find_or_create_contact
|
find_or_create_contact
|
||||||
create_conversation
|
create_conversation
|
||||||
create_message
|
create_message
|
||||||
add_attachments_to_message
|
add_attachments_to_message
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class MailPresenter < SimpleDelegator
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_content
|
def text_content
|
||||||
@decoded_text_content ||= encode_to_unicode(text_part&.decoded || mail.decoded || '')
|
@decoded_text_content ||= encode_to_unicode(text_part&.decoded || decoded_message || '')
|
||||||
|
|
||||||
return {} if @decoded_text_content.blank?
|
return {} if @decoded_text_content.blank?
|
||||||
|
|
||||||
|
@ -47,6 +47,14 @@ class MailPresenter < SimpleDelegator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decoded_message
|
||||||
|
if mail.multipart?
|
||||||
|
return mail.text_part ? mail.text_part.decoded : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
mail.decoded
|
||||||
|
end
|
||||||
|
|
||||||
def number_of_attachments
|
def number_of_attachments
|
||||||
mail.attachments.count
|
mail.attachments.count
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue