@@ -194,6 +194,12 @@ impl<S: MutinyStorage> HermesClient<S> {
194194
195195 // user has a federation registered but is different than current
196196 // so we should update it
197+ log_info ! (
198+ logger_check_clone,
199+ "registered federation is different, changing {:?} to {:?}" ,
200+ o. federation_id,
201+ f. federation_id
202+ ) ;
197203 match change_federation_info (
198204 & http_client_check_clone,
199205 & base_url_check_clone,
@@ -204,7 +210,12 @@ impl<S: MutinyStorage> HermesClient<S> {
204210 )
205211 . await
206212 {
207- Ok ( _) => ( ) ,
213+ Ok ( _) => {
214+ log_debug ! (
215+ logger_check_clone,
216+ "changed federation successfully"
217+ ) ;
218+ }
208219 Err ( e) => {
209220 log_error ! (
210221 logger_check_clone,
@@ -216,6 +227,10 @@ impl<S: MutinyStorage> HermesClient<S> {
216227 // handle the case where the user no longer has a federation
217228 // if user is already disabled, no need to call again
218229 if !o. disabled_zaps {
230+ log_info ! (
231+ logger_check_clone,
232+ "user no longer has a federation, disabling zaps"
233+ ) ;
219234 match disable_zaps (
220235 & http_client_check_clone,
221236 & base_url_check_clone,
@@ -225,7 +240,12 @@ impl<S: MutinyStorage> HermesClient<S> {
225240 )
226241 . await
227242 {
228- Ok ( _) => ( ) ,
243+ Ok ( _) => {
244+ log_debug ! (
245+ logger_check_clone,
246+ "disabled zaps successfully"
247+ ) ;
248+ }
229249 Err ( e) => {
230250 log_error ! (
231251 logger_check_clone,
@@ -480,6 +500,10 @@ async fn change_federation_info(
480500) -> Result < ( ) , MutinyError > {
481501 // make sure name is registered already
482502 if current_address. read ( ) . await . 0 . is_none ( ) {
503+ log_warn ! (
504+ logger,
505+ "can't change federation when the address is unknown"
506+ ) ;
483507 return Ok ( ( ) ) ;
484508 }
485509
@@ -492,9 +516,12 @@ async fn change_federation_info(
492516 let url = Url :: parse ( & format ! ( "{}/v1/change-federation" , base_url) )
493517 . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
494518 let request = http_client. request ( Method :: POST , url) . json ( & event) ;
495- let _ = utils:: fetch_with_timeout ( http_client, request. build ( ) . expect ( "should build req" ) )
496- . await
497- . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
519+ let _ = utils:: fetch_with_timeout (
520+ http_client,
521+ request. build ( ) . map_err ( |_| MutinyError :: ConnectionFailed ) ?,
522+ )
523+ . await
524+ . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
498525
499526 log_info ! ( logger, "changed federation info to current federation" ) ;
500527
@@ -510,6 +537,7 @@ async fn disable_zaps(
510537) -> Result < ( ) , MutinyError > {
511538 // make sure name is registered already
512539 if current_address. read ( ) . await . 0 . is_none ( ) {
540+ log_warn ! ( logger, "can't disable zaps when the address is unknown" ) ;
513541 return Ok ( ( ) ) ;
514542 }
515543
@@ -522,9 +550,12 @@ async fn disable_zaps(
522550 let url = Url :: parse ( & format ! ( "{}/v1/disable-zaps" , base_url) )
523551 . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
524552 let request = http_client. request ( Method :: POST , url) . json ( & event) ;
525- let _ = utils:: fetch_with_timeout ( http_client, request. build ( ) . expect ( "should build req" ) )
526- . await
527- . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
553+ let _ = utils:: fetch_with_timeout (
554+ http_client,
555+ request. build ( ) . map_err ( |_| MutinyError :: ConnectionFailed ) ?,
556+ )
557+ . await
558+ . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
528559
529560 log_info ! ( logger, "disabled zaps for the user" ) ;
530561
@@ -562,11 +593,14 @@ async fn check_hermes_registration_info(
562593 let url = Url :: parse ( & format ! ( "{}/v1/check-registration" , base_url) )
563594 . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
564595 let request = http_client. request ( Method :: POST , url) . json ( & event) ;
565- let res = utils:: fetch_with_timeout ( http_client, request. build ( ) . expect ( "should build req" ) )
566- . await ?
567- . json :: < RegistrationInfo > ( )
568- . await
569- . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
596+ let res = utils:: fetch_with_timeout (
597+ http_client,
598+ request. build ( ) . map_err ( |_| MutinyError :: ConnectionFailed ) ?,
599+ )
600+ . await ?
601+ . json :: < RegistrationInfo > ( )
602+ . await
603+ . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
570604
571605 Ok ( res)
572606}
@@ -580,11 +614,14 @@ async fn check_name_request(
580614 . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
581615 let request = http_client. request ( Method :: GET , url) ;
582616
583- let res = utils:: fetch_with_timeout ( http_client, request. build ( ) . expect ( "should build req" ) )
584- . await ?
585- . json :: < bool > ( )
586- . await
587- . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
617+ let res = utils:: fetch_with_timeout (
618+ http_client,
619+ request. build ( ) . map_err ( |_| MutinyError :: ConnectionFailed ) ?,
620+ )
621+ . await ?
622+ . json :: < bool > ( )
623+ . await
624+ . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
588625
589626 Ok ( res)
590627}
@@ -598,11 +635,14 @@ async fn register_name(
598635 . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
599636 let request = http_client. request ( Method :: POST , url) . json ( & req) ;
600637
601- let res = utils:: fetch_with_timeout ( http_client, request. build ( ) . expect ( "should build req" ) )
602- . await ?
603- . json :: < RegisterResponse > ( )
604- . await
605- . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
638+ let res = utils:: fetch_with_timeout (
639+ http_client,
640+ request. build ( ) . map_err ( |_| MutinyError :: ConnectionFailed ) ?,
641+ )
642+ . await ?
643+ . json :: < RegisterResponse > ( )
644+ . await
645+ . map_err ( |_| MutinyError :: ConnectionFailed ) ?;
606646
607647 Ok ( res)
608648}
0 commit comments