Skip to content

Commit

Permalink
Add validation in route for updating job priority
Browse files Browse the repository at this point in the history
* Do the same validation as in newly introduced parsing of the `_PRIORITY`
  setting
* Use less verbose coding style
* See https://progress.opensuse.org/issues/162029
  • Loading branch information
Martchus committed Aug 7, 2024
1 parent 321977b commit 6fc4e62
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/OpenQA/WebAPI/Controller/API/V1/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,12 @@ Sets priority for a given job.

sub prio ($self) {
return unless my $job = $self->find_job_or_render_not_found($self->stash('jobid'));
my $res = $job->set_prio($self->param('prio'));
my $v = $self->validation;
my $prio = $v->required('prio')->num->param;
return $self->reply->validation_error({format => 'json'}) if $v->has_error;

# Referencing the scalar will result in true or false
# (see http://mojolicio.us/perldoc/Mojo/JSON)
$self->render(json => {result => \$res});
# Referencing the scalar will result in true or false (see http://mojolicio.us/perldoc/Mojo/JSON)
$self->render(json => {result => \$job->set_prio($prio)});
}

=over 4
Expand Down

0 comments on commit 6fc4e62

Please sign in to comment.