@@ -280,7 +280,7 @@ async fn execute_for_other_user(
280
280
id : user. user_id ,
281
281
email : & user. email ,
282
282
} ,
283
- content : & message
283
+ content : & message,
284
284
}
285
285
. send ( ctx. github . raw ( ) )
286
286
. await ;
@@ -380,10 +380,34 @@ impl<'a> MessageApiRequest<'a> {
380
380
pub async fn send ( & self , client : & reqwest:: Client ) -> anyhow:: Result < reqwest:: Response > {
381
381
let bot_api_token = env:: var ( "ZULIP_API_TOKEN" ) . expect ( "ZULIP_API_TOKEN" ) ;
382
382
383
+ #[ derive( serde:: Serialize ) ]
384
+ struct SerializedApi < ' a > {
385
+ #[ serde( rename = "type" ) ]
386
+ type_ : & ' static str ,
387
+ to : String ,
388
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
389
+ topic : Option < & ' a str > ,
390
+ content : & ' a str ,
391
+ }
392
+
383
393
Ok ( client
384
394
. post ( "https://rust-lang.zulipchat.com/api/v1/messages" )
385
395
. basic_auth ( BOT_EMAIL , Some ( & bot_api_token) )
386
- . form ( & self )
396
+ . form ( & SerializedApi {
397
+ type_ : match self . recipient {
398
+ Recipient :: Stream { .. } => "stream" ,
399
+ Recipient :: Private { .. } => "private" ,
400
+ } ,
401
+ to : match self . recipient {
402
+ Recipient :: Stream { id, .. } => id. to_string ( ) ,
403
+ Recipient :: Private { email, .. } => email. to_string ( ) ,
404
+ } ,
405
+ topic : match self . recipient {
406
+ Recipient :: Stream { topic, .. } => Some ( topic) ,
407
+ Recipient :: Private { .. } => None ,
408
+ } ,
409
+ content : self . content ,
410
+ } )
387
411
. send ( )
388
412
. await ?)
389
413
}
0 commit comments