From 8a0a1034955544ee2e4c1f85317c0db84f3aa55b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 28 Sep 2018 12:19:43 -0700 Subject: ActionMailroom -> ActionMailbox We didn't end up using the mailroom metaphor directly, so let's stick with a more conventional naming strategy. --- app/controllers/.DS_Store | Bin 0 -> 6148 bytes .../action_mailbox/inbound_emails_controller.rb | 17 +++++++++++++ .../action_mailroom/inbound_emails_controller.rb | 17 ------------- app/controllers/rails/.DS_Store | Bin 0 -> 6148 bytes .../action_mailbox/inbound_emails_controller.rb | 27 +++++++++++++++++++++ .../action_mailbox/reroutes_controller.rb | 14 +++++++++++ .../action_mailroom/inbound_emails_controller.rb | 27 --------------------- .../action_mailroom/reroutes_controller.rb | 14 ----------- 8 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 app/controllers/.DS_Store create mode 100644 app/controllers/action_mailbox/inbound_emails_controller.rb delete mode 100644 app/controllers/action_mailroom/inbound_emails_controller.rb create mode 100644 app/controllers/rails/.DS_Store create mode 100644 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb create mode 100644 app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb delete mode 100644 app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb delete mode 100644 app/controllers/rails/conductor/action_mailroom/reroutes_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/.DS_Store b/app/controllers/.DS_Store new file mode 100644 index 0000000000..ea1205963a Binary files /dev/null and b/app/controllers/.DS_Store differ diff --git a/app/controllers/action_mailbox/inbound_emails_controller.rb b/app/controllers/action_mailbox/inbound_emails_controller.rb new file mode 100644 index 0000000000..ec9bd6f229 --- /dev/null +++ b/app/controllers/action_mailbox/inbound_emails_controller.rb @@ -0,0 +1,17 @@ +# TODO: Add access protection using basic auth with verified tokens. Maybe coming from credentials by default? +# TODO: Spam/malware catching? +# TODO: Specific bounces for SMTP good citizenship: 200/404/400 +class ActionMailbox::InboundEmailsController < ActionController::Base + skip_forgery_protection + before_action :require_rfc822_message, only: :create + + def create + ActionMailbox::InboundEmail.create_and_extract_message_id!(params[:message]) + head :created + end + + private + def require_rfc822_message + head :unsupported_media_type unless params.require(:message).content_type == 'message/rfc822' + end +end diff --git a/app/controllers/action_mailroom/inbound_emails_controller.rb b/app/controllers/action_mailroom/inbound_emails_controller.rb deleted file mode 100644 index 57e0530ac6..0000000000 --- a/app/controllers/action_mailroom/inbound_emails_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -# TODO: Add access protection using basic auth with verified tokens. Maybe coming from credentials by default? -# TODO: Spam/malware catching? -# TODO: Specific bounces for SMTP good citizenship: 200/404/400 -class ActionMailroom::InboundEmailsController < ActionController::Base - skip_forgery_protection - before_action :require_rfc822_message, only: :create - - def create - ActionMailroom::InboundEmail.create_and_extract_message_id!(params[:message]) - head :created - end - - private - def require_rfc822_message - head :unsupported_media_type unless params.require(:message).content_type == 'message/rfc822' - end -end diff --git a/app/controllers/rails/.DS_Store b/app/controllers/rails/.DS_Store new file mode 100644 index 0000000000..627263b12d Binary files /dev/null and b/app/controllers/rails/.DS_Store differ diff --git a/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb b/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb new file mode 100644 index 0000000000..70537da9c4 --- /dev/null +++ b/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb @@ -0,0 +1,27 @@ +class Rails::Conductor::ActionMailbox::InboundEmailsController < Rails::Conductor::BaseController + def index + @inbound_emails = ActionMailbox::InboundEmail.order(created_at: :desc) + end + + def new + end + + def show + @inbound_email = ActionMailbox::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).to_h + end + + def create_inbound_email(mail) + ActionMailbox::InboundEmail.create! raw_email: \ + { io: StringIO.new(mail.to_s), filename: 'inbound.eml', content_type: 'message/rfc822', identify: false } + end +end diff --git a/app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb b/app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb new file mode 100644 index 0000000000..226116a3d6 --- /dev/null +++ b/app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb @@ -0,0 +1,14 @@ +class Rails::Conductor::ActionMailbox::ReroutesController < Rails::Conductor::BaseController + def create + inbound_email = ActionMailbox::InboundEmail.find(params[:inbound_email_id]) + reroute inbound_email + + redirect_to main_app.rails_conductor_inbound_email_url(inbound_email) + end + + private + def reroute(inbound_email) + inbound_email.pending! + inbound_email.route_later + end +end diff --git a/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb b/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb deleted file mode 100644 index a5a1f34929..0000000000 --- a/app/controllers/rails/conductor/action_mailroom/inbound_emails_controller.rb +++ /dev/null @@ -1,27 +0,0 @@ -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).to_h - end - - def create_inbound_email(mail) - ActionMailroom::InboundEmail.create! raw_email: \ - { io: StringIO.new(mail.to_s), filename: 'inbound.eml', content_type: 'message/rfc822', identify: false } - end -end diff --git a/app/controllers/rails/conductor/action_mailroom/reroutes_controller.rb b/app/controllers/rails/conductor/action_mailroom/reroutes_controller.rb deleted file mode 100644 index 028ed9e2d6..0000000000 --- a/app/controllers/rails/conductor/action_mailroom/reroutes_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Rails::Conductor::ActionMailroom::ReroutesController < Rails::Conductor::BaseController - def create - inbound_email = ActionMailroom::InboundEmail.find(params[:inbound_email_id]) - reroute inbound_email - - redirect_to main_app.rails_conductor_inbound_email_url(inbound_email) - end - - private - def reroute(inbound_email) - inbound_email.pending! - inbound_email.route_later - end -end -- cgit v1.2.3