1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add rerouting option

This commit is contained in:
David Heinemeier Hansson 2018-09-28 11:32:44 -07:00
parent c9d8f6650d
commit 5ad0813322
4 changed files with 21 additions and 5 deletions

View file

@ -0,0 +1,14 @@
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

View file

@ -5,8 +5,7 @@ module ActionMailroom::InboundEmail::Routable
after_create_commit :route_later, if: ->(inbound_email) { inbound_email.pending? }
end
private
def route_later
ActionMailroom::RoutingJob.perform_later self
end
def route_later
ActionMailroom::RoutingJob.perform_later self
end
end

View file

@ -3,7 +3,7 @@
<h1><%= @inbound_email.message_id %>: <%= @inbound_email.status %></h1>
<ul>
<li>Retry</li>
<li><%= button_to "Route again", main_app.rails_conductor_inbound_email_reroute_path(@inbound_email), method: :post %></li>
<li>Incinerate</li>
</ul>
@ -11,3 +11,5 @@
<summary>Full email source</summary>
<pre><%= @inbound_email.source %></pre>
</details>
<%= link_to "Back to all inbound emails", main_app.rails_conductor_inbound_emails_path %>

View file

@ -6,5 +6,6 @@ Rails.application.routes.draw do
# TODO: Should these be mounted within the engine only?
scope "rails/conductor/action_mailroom/", module: "rails/conductor/action_mailroom" do
resources :inbound_emails, as: :rails_conductor_inbound_emails
post ":inbound_email_id/reroute" => "reroutes#create", as: :rails_conductor_inbound_email_reroute
end
end