From 7307ef8128848088c8bae8b7c23b3b11467776e0 Mon Sep 17 00:00:00 2001 From: Lukas Erlacher Date: Thu, 2 Jan 2025 10:59:21 +1100 Subject: [PATCH] squashme: fixes --- lib/Synergy/Reactor/Page.pm | 15 ++++++--------- lib/Synergy/Reactor/PagerDuty.pm | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/Synergy/Reactor/Page.pm b/lib/Synergy/Reactor/Page.pm index c1c05d4f..551b4bc7 100644 --- a/lib/Synergy/Reactor/Page.pm +++ b/lib/Synergy/Reactor/Page.pm @@ -57,7 +57,6 @@ Special On-Call paging: • *page /all oncall: `MESSAGE`*: send this message to all oncall engineers END } => async sub ($self, $event, $rest) { - #my ($who, $what) = $event->text =~ m/^page\s+@?([a-z]+):?\s+(.*)/is; # I've implemented half of a getopt parser here... sorry my $opt_all = 0; my @args; @@ -80,8 +79,9 @@ END return await $event->error_reply("usage: page USER: MESSAGE"); } - my $who = $args[0] =~ s/:$//r; - my $what = join ' ', @args[1 .. $#args]; + my $who = shift @args; + $who = ($who =~ s/:$//r); + my $what = join ' ', @args; my @to_page; if ($who eq 'oncall') { @@ -92,12 +92,9 @@ END # eagerly enough. That should probably be made into a lazily cached # attribute like we use for (for example) the Slack user list. But we # can do that in the future. -- rjbs, 2023-10-18 - my @oncall_ids; - if ($opt_all) { - @oncall_ids = await $pd->_escalation_oncalls; - } else { - @oncall_ids = await $pd->_current_oncall_ids; - } + my @oncall_ids = $opt_all + ? await $pd->_escalation_oncall_ids + : await $pd->_current_oncall_ids; @to_page = grep {; $_ } map {; $pd->username_from_pd($_) } @oncall_ids; } else { $Logger->log("Unable to find reactor 'pagerduty'") unless $pd; diff --git a/lib/Synergy/Reactor/PagerDuty.pm b/lib/Synergy/Reactor/PagerDuty.pm index 74924deb..6140061d 100644 --- a/lib/Synergy/Reactor/PagerDuty.pm +++ b/lib/Synergy/Reactor/PagerDuty.pm @@ -739,7 +739,7 @@ sub _current_oncall_ids ($self) { # returns all the oncall users on the final escalation rule # used for "page all oncall engineers" -sub _escalation_oncalls ($self) { +sub _escalation_oncall_ids ($self) { my $policy_id = $self->escalation_policy_id; return $self->_pd_request(GET => '/escalation_policies/' . $policy_id)