From f19736af140bc591b4a70b872b55acb638b016ab Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 11 Sep 2023 17:02:10 +0100 Subject: [PATCH] AdminIncomingMessageController#redeliver style Minor style fixes: * Line spacing * Line length * Quote style * Interpolation * Variable assignment --- .../admin_incoming_message_controller.rb | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin_incoming_message_controller.rb b/app/controllers/admin_incoming_message_controller.rb index e70d3f99909..d45697eb72b 100644 --- a/app/controllers/admin_incoming_message_controller.rb +++ b/app/controllers/admin_incoming_message_controller.rb @@ -78,30 +78,34 @@ def bulk_destroy end def redeliver - - message_ids = params[:url_title].split(",").each(&:strip) + message_ids = params[:url_title].split(',').each(&:strip) previous_request = @incoming_message.info_request destination_request = nil if message_ids.empty? - flash[:error] = "You must supply at least one request to redeliver the message to." + flash[:error] = + 'You must supply at least one request to redeliver the message to.' + return redirect_to admin_request_url(previous_request) end ActiveRecord::Base.transaction do message_ids.each do |m| - if m.match(/^[0-9]+$/) - destination_request = InfoRequest.find_by_id(m.to_i) - else - destination_request = InfoRequest.find_by_url_title!(m) - end + destination_request = + if m.match(/^[0-9]+$/) + InfoRequest.find_by_id(m.to_i) + else + InfoRequest.find_by_url_title!(m) + end + if destination_request.nil? - flash[:error] = "Failed to find destination request '" + m + "'" + flash[:error] = "Failed to find destination request '#{m}'" return redirect_to admin_request_url(previous_request) end raw_email_data = @incoming_message.raw_email.data mail = MailHandler.mail_from_raw_email(raw_email_data) + destination_request. receive(mail, raw_email_data, @@ -114,12 +118,15 @@ def redeliver deleted_incoming_message_id: @incoming_message.id ) - flash[:notice] = "Message has been moved to request(s). Showing the last one:" + flash[:notice] = + 'Message has been moved to request(s). Showing the last one:' end + # expire cached files previous_request.expire @incoming_message.destroy end + redirect_to admin_request_url(destination_request) end