Skip to content

Commit f6b2970

Browse files
authored
Merge pull request #1974 from Urgau/notify_zulip-opened
notify_zulip: handle labels set when opening the pr
2 parents 6a9c532 + 681ee1f commit f6b2970

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/handlers/notify_zulip.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(super) struct NotifyZulipInput {
1818
}
1919

2020
pub(super) enum NotificationType {
21+
Open,
2122
Labeled,
2223
Unlabeled,
2324
Closed,
@@ -45,8 +46,8 @@ pub(super) async fn parse_input(
4546
})
4647
.map(|input| vec![input]))
4748
}
48-
IssuesAction::Closed | IssuesAction::Reopened => {
49-
Ok(Some(parse_close_reopen_input(event, config)))
49+
IssuesAction::Opened | IssuesAction::Closed | IssuesAction::Reopened => {
50+
Ok(Some(parse_open_close_reopen_input(event, config)))
5051
}
5152
_ => Ok(None),
5253
}
@@ -93,7 +94,7 @@ fn parse_label_change_input(
9394
}
9495
}
9596

96-
fn parse_close_reopen_input(
97+
fn parse_open_close_reopen_input(
9798
event: &IssuesEvent,
9899
global_config: &NotifyZulipConfig,
99100
) -> Vec<NotifyZulipInput> {
@@ -114,6 +115,9 @@ fn parse_close_reopen_input(
114115
for (name, label_config) in &config.subtables {
115116
if has_all_required_labels(&event.issue, &label_config) {
116117
match event.action {
118+
IssuesAction::Opened if !label_config.messages_on_add.is_empty() => {
119+
include_config_names.push(name.to_string());
120+
}
117121
IssuesAction::Closed if !label_config.messages_on_close.is_empty() => {
118122
include_config_names.push(name.to_string());
119123
}
@@ -131,6 +135,11 @@ fn parse_close_reopen_input(
131135
}
132136

133137
match event.action {
138+
IssuesAction::Opened => Some(NotifyZulipInput {
139+
notification_type: NotificationType::Open,
140+
label,
141+
include_config_names,
142+
}),
134143
IssuesAction::Closed => Some(NotifyZulipInput {
135144
notification_type: NotificationType::Closed,
136145
label,
@@ -193,7 +202,7 @@ pub(super) async fn handle_input<'a>(
193202
}
194203

195204
let msgs = match input.notification_type {
196-
NotificationType::Labeled => &config.messages_on_add,
205+
NotificationType::Open | NotificationType::Labeled => &config.messages_on_add,
197206
NotificationType::Unlabeled => &config.messages_on_remove,
198207
NotificationType::Closed => &config.messages_on_close,
199208
NotificationType::Reopened => &config.messages_on_reopen,

0 commit comments

Comments
 (0)