From b3919d01554d31c5486d17332f4a4dde89a23239 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Thu, 18 Oct 2018 10:23:17 -0400 Subject: Don't require Postfix to send form data --- app/models/action_mailbox/inbound_email/message_id.rb | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'app/models/action_mailbox/inbound_email/message_id.rb') diff --git a/app/models/action_mailbox/inbound_email/message_id.rb b/app/models/action_mailbox/inbound_email/message_id.rb index 601c5f1a7e..5cfcadaba1 100644 --- a/app/models/action_mailbox/inbound_email/message_id.rb +++ b/app/models/action_mailbox/inbound_email/message_id.rb @@ -6,20 +6,15 @@ module ActionMailbox::InboundEmail::MessageId end module ClassMethods - def create_and_extract_message_id!(raw_email, **options) - create! message_id: extract_message_id(raw_email), **options do |inbound_email| - case raw_email - when ActionDispatch::Http::UploadedFile - inbound_email.raw_email.attach raw_email - else - inbound_email.raw_email.attach io: raw_email.tap(&:rewind), filename: "message.eml", content_type: "message/rfc822" - end + def create_and_extract_message_id!(source, **options) + create! message_id: extract_message_id(source), **options do |inbound_email| + inbound_email.raw_email.attach io: StringIO.new(source), filename: "message.eml", content_type: "message/rfc822" end end private - def extract_message_id(raw_email) - mail_from_source(raw_email.read).message_id + def extract_message_id(source) + mail_from_source(source).message_id rescue => e # FIXME: Add logging with "Couldn't extract Message ID, so will generating a new random ID instead" end -- cgit v1.2.3