From d49f503af84b5cbe89d7f6258cdf4a93ca6b93f4 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 15 May 2025 15:20:44 +0200 Subject: [PATCH] Don't redirect if not needed --- app/controllers/commands_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/commands_controller.rb b/app/controllers/commands_controller.rb index 00a1bec42..4424f5ca2 100644 --- a/app/controllers/commands_controller.rb +++ b/app/controllers/commands_controller.rb @@ -29,7 +29,7 @@ class CommandsController < ApplicationController end def parsing_context - Command::Parser::Context.new(Current.user, url: request.referrer) + @parsing_context ||= Command::Parser::Context.new(Current.user, url: request.referrer) end def confirmed?(command) @@ -50,7 +50,8 @@ class CommandsController < ApplicationController end def respond_with_needs_confirmation(command) - render json: { confirmation: command.confirmation_prompt, redirect_to: command.context.url }, status: :conflict + redirection_url = command.context.url unless command.context.url == parsing_context.url + render json: { confirmation: command.confirmation_prompt, redirect_to: redirection_url }, status: :conflict end def respond_with_composite_response(results)