@@ -60,11 +60,13 @@ fn parse_label_change_input(
60
60
}
61
61
62
62
match event. action {
63
- IssuesAction :: Labeled { .. } if config. message_on_add . is_some ( ) => Some ( NotifyZulipInput {
64
- notification_type : NotificationType :: Labeled ,
65
- label,
66
- } ) ,
67
- IssuesAction :: Unlabeled { .. } if config. message_on_remove . is_some ( ) => {
63
+ IssuesAction :: Labeled { .. } if !config. messages_on_add . is_empty ( ) => {
64
+ Some ( NotifyZulipInput {
65
+ notification_type : NotificationType :: Labeled ,
66
+ label,
67
+ } )
68
+ }
69
+ IssuesAction :: Unlabeled { .. } if !config. messages_on_remove . is_empty ( ) => {
68
70
Some ( NotifyZulipInput {
69
71
notification_type : NotificationType :: Unlabeled ,
70
72
label,
@@ -96,13 +98,13 @@ fn parse_close_reopen_input(
96
98
}
97
99
98
100
match event. action {
99
- IssuesAction :: Closed if config. message_on_close . is_some ( ) => {
101
+ IssuesAction :: Closed if ! config. messages_on_close . is_empty ( ) => {
100
102
Some ( NotifyZulipInput {
101
103
notification_type : NotificationType :: Closed ,
102
104
label,
103
105
} )
104
106
}
105
- IssuesAction :: Reopened if config. message_on_reopen . is_some ( ) => {
107
+ IssuesAction :: Reopened if ! config. messages_on_reopen . is_empty ( ) => {
106
108
Some ( NotifyZulipInput {
107
109
notification_type : NotificationType :: Reopened ,
108
110
label,
@@ -140,34 +142,39 @@ pub(super) async fn handle_input<'a>(
140
142
for input in inputs {
141
143
let config = & config. labels [ & input. label . name ] ;
142
144
143
- let mut topic = config. topic . clone ( ) ;
144
- topic = topic. replace ( "{number}" , & event. issue . number . to_string ( ) ) ;
145
- topic = topic. replace ( "{title}" , & event. issue . title ) ;
145
+ let topic = & config. topic ;
146
+ let topic = topic. replace ( "{number}" , & event. issue . number . to_string ( ) ) ;
147
+ let mut topic = topic. replace ( "{title}" , & event. issue . title ) ;
146
148
// Truncate to 60 chars (a Zulip limitation)
147
149
let mut chars = topic. char_indices ( ) . skip ( 59 ) ;
148
150
if let ( Some ( ( len, _) ) , Some ( _) ) = ( chars. next ( ) , chars. next ( ) ) {
149
151
topic. truncate ( len) ;
150
152
topic. push ( '…' ) ;
151
153
}
152
154
153
- let mut msg = match input. notification_type {
154
- NotificationType :: Labeled => config. message_on_add . as_ref ( ) . unwrap ( ) . clone ( ) ,
155
- NotificationType :: Unlabeled => config. message_on_remove . as_ref ( ) . unwrap ( ) . clone ( ) ,
156
- NotificationType :: Closed => config. message_on_close . as_ref ( ) . unwrap ( ) . clone ( ) ,
157
- NotificationType :: Reopened => config. message_on_reopen . as_ref ( ) . unwrap ( ) . clone ( ) ,
155
+ let msgs = match input. notification_type {
156
+ NotificationType :: Labeled => & config. messages_on_add ,
157
+ NotificationType :: Unlabeled => & config. messages_on_remove ,
158
+ NotificationType :: Closed => & config. messages_on_close ,
159
+ NotificationType :: Reopened => & config. messages_on_reopen ,
158
160
} ;
159
161
160
- msg = msg. replace ( "{number}" , & event. issue . number . to_string ( ) ) ;
161
- msg = msg. replace ( "{title}" , & event. issue . title ) ;
162
-
163
- let zulip_req = crate :: zulip:: MessageApiRequest {
164
- recipient : crate :: zulip:: Recipient :: Stream {
165
- id : config. zulip_stream ,
166
- topic : & topic,
167
- } ,
168
- content : & msg,
162
+ let recipient = crate :: zulip:: Recipient :: Stream {
163
+ id : config. zulip_stream ,
164
+ topic : & topic,
169
165
} ;
170
- zulip_req. send ( & ctx. github . raw ( ) ) . await ?;
166
+
167
+ for msg in msgs {
168
+ let msg = msg. replace ( "{number}" , & event. issue . number . to_string ( ) ) ;
169
+ let msg = msg. replace ( "{title}" , & event. issue . title ) ;
170
+
171
+ crate :: zulip:: MessageApiRequest {
172
+ recipient,
173
+ content : & msg,
174
+ }
175
+ . send ( & ctx. github . raw ( ) )
176
+ . await ?;
177
+ }
171
178
}
172
179
173
180
Ok ( ( ) )
0 commit comments