Instead of removing uncofirmed commands don't create them in the first place
This commit is contained in:
@@ -6,12 +6,12 @@ class CommandsController < ApplicationController
|
||||
def create
|
||||
command = parse_command(params[:command])
|
||||
|
||||
if command&.valid?
|
||||
if command.valid?
|
||||
if confirmed?(command)
|
||||
command.save!
|
||||
result = command.execute
|
||||
respond_with_execution_result(result)
|
||||
else
|
||||
command.destroy
|
||||
render plain: command.title, status: :conflict
|
||||
end
|
||||
else
|
||||
@@ -21,9 +21,7 @@ class CommandsController < ApplicationController
|
||||
|
||||
private
|
||||
def parse_command(string)
|
||||
Command::Parser.new(parsing_context).parse(string).tap do |command|
|
||||
Current.user.commands << command
|
||||
end
|
||||
Command::Parser.new(parsing_context).parse(string)
|
||||
end
|
||||
|
||||
def parsing_context
|
||||
|
||||
@@ -9,7 +9,8 @@ class Command::Parser
|
||||
|
||||
def parse(string)
|
||||
parse_command(string).tap do |command|
|
||||
command&.line = string
|
||||
command.user = user
|
||||
command.line = string
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user