iachat/spec/fixtures/files
Pranav 8cdbdaaa07
fix: Process attachments as regular attachments if the text/plain or text/html part is empty (#10379)
Some email clients automatically set Content-Disposition to inline for
specific content types, such as images. In cases where the email body is
empty, inline attachments may not display correctly due to our previous
implementation. Our assumption was that these attachments are referenced
within text/plain or text/html parts.

Customer-reported issues, especially with Apple Mail, show emails with
attachments marked as inline but without any corresponding text parts.
This leads to missing attachments even though would have processed the
attachment.

This update introduces a check for the presence of a text part. If none
exists, inline attachments are treated as regular attachments and added
to the external attachments array, ensuring that all attachments display
properly.

<details>
<summary><b>Script to update the existing emails that are already
available in the system</b></summary>

```rb
def update_content id
  message = Message.find id
  conversation = message.conversation
  message_id = message.source_id

  channel = message.inbox.channel

  authentication_type = 'XOAUTH2'
  imap_password = Google::RefreshOauthTokenService.new(channel: channel).access_token
  imap = Net::IMAP.new(channel.imap_address, port: channel.imap_port, ssl: true)
  imap.authenticate(authentication_type, channel.imap_login, imap_password)
  imap.select('INBOX')

  results = imap.search(['HEADER', 'MESSAGE-ID', message_id])
  message_content = imap.fetch(results.first, 'RFC822').first.attr['RFC822']
  mail = MailPresenter.new(Mail.read_from_string(message_content))

  mail_content = if mail.text_content.present?
                   mail.text_content[:reply]
                 elsif mail.html_content.present?
                   mail.html_content[:reply]
                 end

  attachments = mail.attachments.last(Message::NUMBER_OF_PERMITTED_ATTACHMENTS)
  inline_attachments = attachments.select { |attachment| attachment[:original].inline? && mail_content.present? }
  regular_attachments = attachments - inline_attachments

  regular_attachments.each do |mail_attachment|
    attachment = message.attachments.new(
      account_id: conversation.account_id,
      file_type: 'file'
    )
    attachment.file.attach(mail_attachment[:blob])
  end

  message.save!
end
```
</details>
2024-11-04 10:25:01 +01:00
..
.keep Fix url in emails, add frontendURL helper (#19) 2019-08-25 19:59:28 +05:30
attachments_without_text.eml fix: Process attachments as regular attachments if the text/plain or text/html part is empty (#10379) 2024-11-04 10:25:01 +01:00
auto_reply_with_auto_submitted.eml chore: Stop processing auto-response emails (#9606) 2024-06-13 14:19:11 -07:00
auto_reply.eml chore: Stop processing auto-response emails (#9606) 2024-06-13 14:19:11 -07:00
bounced_with_no_from.eml chore: Fix sentry errors in email processing for bounce notifications (#8677) 2024-01-10 14:30:23 -08:00
forwarder_email.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
group_sender_support.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
html_and_attachments.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
in_reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
mail_with_html_part_no_html_content.eml fix: Update mail check for html_part (#7273) 2023-06-09 16:08:40 +05:30
mail_with_inline_images.eml fix: Update inline image processing logic to fix missing images when multiple inline images present (#7861) 2023-09-06 14:35:19 +05:30
mail_with_invalid_to_2.eml fix: Raise error if email to_header is invalid (#8688) 2024-02-20 17:03:39 -08:00
mail_with_invalid_to.eml fix: Raise error if email to_header is invalid (#8688) 2024-02-20 17:03:39 -08:00
mail_with_no_date.eml fix: Use BODY.PEEK[HEADER] to avoid parsing issues with mail providers (#8833) 2024-02-01 17:24:59 -08:00
mail_with_no_subject.eml fix: Handle email with no subject line and no body (#2164) 2021-04-27 10:51:04 -07:00
mail_with_plain_text_and_inline_image.eml fix: Update inline image processing logic to fix missing images when multiple inline images present (#7861) 2023-09-06 14:35:19 +05:30
mail_with_quote.eml Fix: Email Parsing for html fix (#3659) 2022-01-20 15:55:35 -08:00
multiple_attachments.eml chore: fetch mails with multiple attachments (#7030) 2023-05-14 10:02:36 +05:30
multiple_in_reply_to.eml fix: Consider the emails where in-reply-to header has multiple values (#7715) 2023-08-11 17:53:57 -07:00
non_utf_encoded_mail.eml Fix: handling UTF encoded mail (#4384) 2022-04-06 12:36:32 +05:30
notification.eml chore: Prevent notification email loop (#3386) 2021-11-15 19:15:51 +05:30
only_attachments.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
only_html.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
only_text.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
references.eml fix: find mail message by references (#7220) 2023-05-31 19:23:29 +05:30
reply_cc.eml Fix: Find mailbox with cc email (#4372) 2022-04-08 11:20:19 +05:30
reply_mail_without_uuid.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
reply.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_1.eml Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
support_in_reply_to.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_uppercase.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support_without_sender_name.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
support.eml fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
welcome_html.eml chore: Improve email parsing using email trimmer gem (#3611) 2021-12-22 18:16:40 +05:30
welcome.eml fix: undefined method contact in support mailbox (#2678) 2021-08-12 01:28:07 +05:30