diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-27 17:39:13 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-27 17:39:13 -0700 |
commit | e1486aa3535005175ae9859daba44b1e1d67f1d1 (patch) | |
tree | d1623ac451b3662531f81ad439a4832dfa144665 /app/controllers/rails/conductor | |
parent | ab92058bbdb3240dca2fbf51d86a720ee7bce1ca (diff) | |
download | rails-e1486aa3535005175ae9859daba44b1e1d67f1d1.tar.gz rails-e1486aa3535005175ae9859daba44b1e1d67f1d1.tar.bz2 rails-e1486aa3535005175ae9859daba44b1e1d67f1d1.zip |
Flesh out conductor interface
Diffstat (limited to 'app/controllers/rails/conductor')
-rw-r--r-- | app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb | 30 | ||||
-rw-r--r-- | app/controllers/rails/conductor/base_controller.rb | 10 |
2 files changed, 40 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 diff --git a/app/controllers/rails/conductor/base_controller.rb b/app/controllers/rails/conductor/base_controller.rb new file mode 100644 index 0000000000..cfa0b84963 --- /dev/null +++ b/app/controllers/rails/conductor/base_controller.rb @@ -0,0 +1,10 @@ +# TODO: Move this to Rails::Conductor gem +class Rails::Conductor::BaseController < ActionController::Base + layout "rails/conductor" + before_action :ensure_development_env + + private + def ensure_development_env + head :forbidden unless Rails.env.development? + end +end |