Skip to content

Commit

Permalink
VO: fix resolve response if there are no incidents
Browse files Browse the repository at this point in the history
Right now, if you say "demaint /resolve", and nothing actually fired,
you'll get "Sorry, something went wrong," which is misleading.
  • Loading branch information
mmcclimon committed Aug 13, 2020
1 parent c32468a commit 9eb98a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Synergy/Reactor/VictorOps.pm
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,18 @@ sub _resolve_incidents($self, $event, $args) {
push @unresolved, $incident->{incidentNumber};
}

unless (@unresolved) {
$event->reply("Looks like there's no incidents to resolve. Lucky!");
return Future->done({ no_incidents => 1 }); # hack
}

return $self->_vo_request(PATCH => "/incidents/resolve", {
userName => $vo_username,
incidentNames => \@unresolved,
});
})->then(sub ($data) {
return Future->done(0) if $data->{no_incidents};

my $n = $data->{results}->@*;
my $noun = $n == 1 ? 'incident' : 'incidents';

Expand Down

0 comments on commit 9eb98a0

Please sign in to comment.