aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/action_mailbox/inbound_email/message_id.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/action_mailbox/inbound_email/message_id.rb')
-rw-r--r--app/models/action_mailbox/inbound_email/message_id.rb15
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