File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -849,18 +849,31 @@ struct AddReaction<'a> {
849
849
}
850
850
851
851
impl < ' a > AddReaction < ' a > {
852
- pub async fn send ( self , client : & reqwest:: Client ) -> anyhow:: Result < reqwest :: Response > {
852
+ pub async fn send ( self , client : & reqwest:: Client ) -> anyhow:: Result < ( ) > {
853
853
let bot_api_token = env:: var ( "ZULIP_API_TOKEN" ) . expect ( "ZULIP_API_TOKEN" ) ;
854
854
855
- Ok ( client
855
+ let resp = client
856
856
. post ( & format ! (
857
857
"{}/api/v1/messages/{}/reactions" ,
858
858
* ZULIP_URL , self . message_id
859
859
) )
860
860
. basic_auth ( & * ZULIP_BOT_EMAIL , Some ( & bot_api_token) )
861
861
. form ( & self )
862
862
. send ( )
863
- . await ?)
863
+ . await ?;
864
+
865
+ let status = resp. status ( ) ;
866
+
867
+ if !status. is_success ( ) {
868
+ let body = resp
869
+ . text ( )
870
+ . await
871
+ . context ( "fail receiving Zulip API response (when adding a reaction)" ) ?;
872
+
873
+ anyhow:: bail!( body)
874
+ }
875
+
876
+ Ok ( ( ) )
864
877
}
865
878
}
866
879
You can’t perform that action at this time.
0 commit comments