1+ use crate :: github:: User ;
12use crate :: zulip:: api:: Recipient ;
3+ use crate :: zulip:: render_zulip_username;
24use crate :: {
35 config:: { NotifyZulipConfig , NotifyZulipLabelConfig , NotifyZulipTablesConfig } ,
46 github:: { Issue , IssuesAction , IssuesEvent , Label } ,
57 handlers:: Context ,
68} ;
9+ use futures:: future:: join_all;
710use tracing as log;
811
912pub ( super ) struct NotifyZulipInput {
@@ -218,6 +221,10 @@ pub(super) async fn handle_input<'a>(
218221 let msg = msg. replace ( "{number}" , & event. issue . number . to_string ( ) ) ;
219222 let msg = msg. replace ( "{title}" , & event. issue . title ) ;
220223 let msg = replace_team_to_be_nominated ( & event. issue . labels , msg) ;
224+ let msg = msg. replace (
225+ "{reviewers}" ,
226+ & retrieve_zulip_ids ( ctx, & event. issue . assignees ) . await ,
227+ ) ;
221228
222229 let req = crate :: zulip:: MessageApiRequest {
223230 recipient,
@@ -236,6 +243,24 @@ pub(super) async fn handle_input<'a>(
236243 Ok ( ( ) )
237244}
238245
246+ /// Retrieve Zulip IDs for PR assignees
247+ async fn retrieve_zulip_ids ( ctx : & Context , assignees : & [ User ] ) -> String {
248+ let gh_ids_fut = assignees
249+ . iter ( )
250+ . map ( |reviewer| async move { ctx. team . github_to_zulip_id ( reviewer. id ) . await } ) ;
251+ let zulip_ids = join_all ( gh_ids_fut) . await ;
252+
253+ zulip_ids
254+ . iter ( )
255+ . map ( |x| {
256+ let id = x. as_ref ( ) . unwrap ( ) . unwrap ( ) ;
257+ render_zulip_username ( id)
258+ } )
259+ . collect :: < Vec < String > > ( )
260+ . join ( ", cc: " )
261+ }
262+
263+ /// Replace the placeholder "{team}" with the correct team name
239264fn replace_team_to_be_nominated ( labels : & [ Label ] , msg : String ) -> String {
240265 let teams = labels
241266 . iter ( )
0 commit comments