aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/action_mailbox/inbound_email/message_id.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-06 22:02:08 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-11 12:51:13 -0400
commit6b7eac5c51cbef4acd1ab7f48884e7b614f71678 (patch)
tree8eb6b0ebee4ad6073f6cb48b3effc60d4262d2f2 /app/models/action_mailbox/inbound_email/message_id.rb
parent47445511862a4c9979fb46889011edf585391091 (diff)
downloadrails-6b7eac5c51cbef4acd1ab7f48884e7b614f71678.tar.gz
rails-6b7eac5c51cbef4acd1ab7f48884e7b614f71678.tar.bz2
rails-6b7eac5c51cbef4acd1ab7f48884e7b614f71678.zip
Accept inbound emails from a variety of ingresses
Diffstat (limited to 'app/models/action_mailbox/inbound_email/message_id.rb')
-rw-r--r--app/models/action_mailbox/inbound_email/message_id.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/action_mailbox/inbound_email/message_id.rb b/app/models/action_mailbox/inbound_email/message_id.rb
index 590dbfc4d7..601c5f1a7e 100644
--- a/app/models/action_mailbox/inbound_email/message_id.rb
+++ b/app/models/action_mailbox/inbound_email/message_id.rb
@@ -7,7 +7,14 @@ module ActionMailbox::InboundEmail::MessageId
module ClassMethods
def create_and_extract_message_id!(raw_email, **options)
- create! raw_email: raw_email, message_id: 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
+ end
end
private