diff options
Diffstat (limited to 'app/models/action_mailbox/inbound_email/message_id.rb')
-rw-r--r-- | app/models/action_mailbox/inbound_email/message_id.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/action_mailbox/inbound_email/message_id.rb b/app/models/action_mailbox/inbound_email/message_id.rb index a1ec5c0437..5cfcadaba1 100644 --- a/app/models/action_mailbox/inbound_email/message_id.rb +++ b/app/models/action_mailbox/inbound_email/message_id.rb @@ -6,14 +6,16 @@ module ActionMailbox::InboundEmail::MessageId end module ClassMethods - def create_and_extract_message_id!(raw_email, **options) - create! raw_email: raw_email, message_id: extract_message_id(raw_email), **options + 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 - rescue + 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 end |