Skip to content

Commit fbe8cd9

Browse files
committed
Configure team in prioritization alerts on Zulip
1 parent c6fa165 commit fbe8cd9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/handlers/notify_zulip.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,31 @@ pub(super) async fn handle_input<'a>(
160160
msg = msg.replace("{number}", &event.issue.number.to_string());
161161
msg = msg.replace("{title}", &event.issue.title);
162162

163+
let teams = event
164+
.issue
165+
.labels
166+
.iter()
167+
.map(|label| &label.name)
168+
.filter_map(|label| label.strip_prefix("T-"))
169+
.collect::<Vec<&str>>();
170+
171+
if teams.is_empty() {
172+
log::debug!("No team label found, please investigate");
173+
} else if teams.len() == 1 {
174+
// If there is a single team label, replace the placeholder straight away
175+
// If there are multiple team labels and one of them is "compiler", pick that one
176+
// (currently the only team handling these Zulip notification)
177+
// if there are multiple team labels and none is "compiler", have someone else take a decision
178+
msg = msg.replace("{team}", teams[0]);
179+
} else if teams.contains(&"compiler") {
180+
msg = msg.replace("{team}", "compiler");
181+
} else {
182+
msg = msg.replace(
183+
"Needs `I-{team}-nominated`?",
184+
"Issue needs to be nominated?",
185+
);
186+
}
187+
163188
let zulip_req = crate::zulip::MessageApiRequest {
164189
recipient: crate::zulip::Recipient::Stream {
165190
id: config.zulip_stream,

0 commit comments

Comments
 (0)