aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-27 17:39:13 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-27 17:39:13 -0700
commite1486aa3535005175ae9859daba44b1e1d67f1d1 (patch)
treed1623ac451b3662531f81ad439a4832dfa144665 /app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb
parentab92058bbdb3240dca2fbf51d86a720ee7bce1ca (diff)
downloadrails-e1486aa3535005175ae9859daba44b1e1d67f1d1.tar.gz
rails-e1486aa3535005175ae9859daba44b1e1d67f1d1.tar.bz2
rails-e1486aa3535005175ae9859daba44b1e1d67f1d1.zip
Flesh out conductor interface
Diffstat (limited to 'app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb')
-rw-r--r--app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb b/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb
new file mode 100644
index 0000000000..2281f5bcae
--- /dev/null
+++ b/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb
@@ -0,0 +1,30 @@
+class Rails::Conductor::ActionMailroom::InboundEmailsController < Rails::Conductor::BaseController
+ def index
+ @inbound_emails = ActionMailroom::InboundEmail.order(created_at: :desc)
+ end
+
+ def new
+ end
+
+ def show
+ @inbound_email = ActionMailroom::InboundEmail.find(params[:id])
+ end
+
+ def create
+ inbound_email = create_inbound_email(new_mail)
+ redirect_to main_app.rails_conductor_inbound_email_url(inbound_email)
+ end
+
+ private
+ def new_mail
+ Mail.new params.require(:mail).permit(:from, :to, :cc, :bcc, :subject, :body)
+ end
+
+ def create_inbound_email(mail)
+ ActionMailroom::InboundEmail.create! raw_email: new_raw_email(mail), message_id: mail.message_id
+ end
+
+ def new_raw_email(mail)
+ { io: StringIO.new(new_mail.to_s), filename: 'inbound.eml', content_type: 'message/rfc822', identify: false }
+ end
+end