diff options
author | George Claghorn <george@basecamp.com> | 2018-10-18 10:23:17 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-10-18 10:23:17 -0400 |
commit | b3919d01554d31c5486d17332f4a4dde89a23239 (patch) | |
tree | 42a4bcacda5f7e88824487b269e2893a96422333 /app/models/action_mailbox/inbound_email | |
parent | 88227658217ee82af7516d6a8013a6c04f037073 (diff) | |
download | rails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.gz rails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.bz2 rails-b3919d01554d31c5486d17332f4a4dde89a23239.zip |
Don't require Postfix to send form data
Diffstat (limited to 'app/models/action_mailbox/inbound_email')
-rw-r--r-- | app/models/action_mailbox/inbound_email/message_id.rb | 15 |
1 files changed, 5 insertions, 10 deletions
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 |