@@ -292,17 +292,13 @@ impl GoogleChatAdapter {
292292 } ;
293293
294294 let formatted = markdown_to_gchat ( text) ;
295- let url = format ! ( "{}/{}?updateMask=text" , self . api_base, message_name) ;
295+ let url = format ! (
296+ "{}/{}?updateMask=text" ,
297+ self . api_base, message_name
298+ ) ;
296299 let body = serde_json:: json!( { "text" : formatted } ) ;
297300
298- match self
299- . client
300- . patch ( & url)
301- . bearer_auth ( & token)
302- . json ( & body)
303- . send ( )
304- . await
305- {
301+ match self . client . patch ( & url) . bearer_auth ( & token) . json ( & body) . send ( ) . await {
306302 Ok ( r) if r. status ( ) . is_success ( ) => {
307303 tracing:: trace!( message_name = %message_name, "googlechat message edited" ) ;
308304 }
@@ -326,8 +322,7 @@ impl GoogleChatAdapter {
326322 match reply. command . as_deref ( ) {
327323 Some ( "add_reaction" ) | Some ( "remove_reaction" ) | Some ( "create_topic" ) => return ,
328324 Some ( "edit_message" ) => {
329- self . edit_message ( & reply. reply_to , & reply. content . text )
330- . await ;
325+ self . edit_message ( & reply. reply_to , & reply. content . text ) . await ;
331326 return ;
332327 }
333328 _ => { }
@@ -463,7 +458,10 @@ pub async fn webhook(
463458
464459 if let Some ( ref adapter) = state. google_chat {
465460 if let Some ( ref verifier) = adapter. jwt_verifier {
466- let auth_header = match headers. get ( "authorization" ) . and_then ( |v| v. to_str ( ) . ok ( ) ) {
461+ let auth_header = match headers
462+ . get ( "authorization" )
463+ . and_then ( |v| v. to_str ( ) . ok ( ) )
464+ {
467465 Some ( h) => h,
468466 None => {
469467 warn ! ( "googlechat webhook: missing authorization header" ) ;
@@ -533,7 +531,12 @@ pub async fn webhook(
533531
534532 let thread_id = msg. thread . as_ref ( ) . map ( |t| t. name . clone ( ) ) ;
535533
536- let message_id = msg. name . rsplit ( '/' ) . next ( ) . unwrap_or ( & msg. name ) . to_string ( ) ;
534+ let message_id = msg
535+ . name
536+ . rsplit ( '/' )
537+ . next ( )
538+ . unwrap_or ( & msg. name )
539+ . to_string ( ) ;
537540
538541 // No attachments → emit event synchronously and respond 200
539542 if media_refs. is_empty ( ) {
@@ -771,9 +774,7 @@ impl GoogleChatTokenCache {
771774 }
772775
773776 async fn refresh ( & self , client : & reqwest:: Client ) -> Result < ( String , u64 ) , String > {
774- let jwt = self
775- . build_jwt ( )
776- . map_err ( |e| format ! ( "JWT build error: {e}" ) ) ?;
777+ let jwt = self . build_jwt ( ) . map_err ( |e| format ! ( "JWT build error: {e}" ) ) ?;
777778 let resp = client
778779 . post ( "https://oauth2.googleapis.com/token" )
779780 . form ( & [
@@ -826,7 +827,8 @@ impl GoogleChatTokenCache {
826827 let key = jsonwebtoken:: EncodingKey :: from_rsa_pem ( self . private_key . as_bytes ( ) )
827828 . map_err ( |e| format ! ( "RSA key parse error: {e}" ) ) ?;
828829 let header = jsonwebtoken:: Header :: new ( jsonwebtoken:: Algorithm :: RS256 ) ;
829- jsonwebtoken:: encode ( & header, & claims, & key) . map_err ( |e| format ! ( "JWT encode error: {e}" ) )
830+ jsonwebtoken:: encode ( & header, & claims, & key)
831+ . map_err ( |e| format ! ( "JWT encode error: {e}" ) )
830832 }
831833}
832834
@@ -1442,10 +1444,7 @@ mod tests {
14421444 let msg = payload. message . as_ref ( ) . unwrap ( ) ;
14431445 assert_eq ! ( msg. argument_text. as_deref( ) , Some ( "hi" ) ) ;
14441446 assert_eq ! ( msg. thread. as_ref( ) . unwrap( ) . name, "spaces/SP/threads/t1" ) ;
1445- assert_eq ! (
1446- payload. space. as_ref( ) . unwrap( ) . space_type. as_deref( ) ,
1447- Some ( "ROOM" )
1448- ) ;
1447+ assert_eq ! ( payload. space. as_ref( ) . unwrap( ) . space_type. as_deref( ) , Some ( "ROOM" ) ) ;
14491448 }
14501449
14511450 #[ test]
@@ -1808,16 +1807,15 @@ mod tests {
18081807
18091808 #[ tokio:: test]
18101809 async fn handle_reply_sends_gateway_response_success ( ) {
1811- use wiremock:: matchers:: { method, path_regex} ;
18121810 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
1811+ use wiremock:: matchers:: { method, path_regex} ;
18131812
18141813 let mock_server = MockServer :: start ( ) . await ;
18151814 Mock :: given ( method ( "POST" ) )
18161815 . and ( path_regex ( "/spaces/.*/messages" ) )
1817- . respond_with (
1818- ResponseTemplate :: new ( 200 )
1819- . set_body_json ( serde_json:: json!( { "name" : "spaces/TEST/messages/msg_abc" } ) ) ,
1820- )
1816+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json (
1817+ serde_json:: json!( { "name" : "spaces/TEST/messages/msg_abc" } ) ,
1818+ ) )
18211819 . mount ( & mock_server)
18221820 . await ;
18231821
@@ -1856,8 +1854,8 @@ mod tests {
18561854
18571855 #[ tokio:: test]
18581856 async fn handle_reply_sends_failure_response_on_api_error ( ) {
1859- use wiremock:: matchers:: { method, path_regex} ;
18601857 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
1858+ use wiremock:: matchers:: { method, path_regex} ;
18611859
18621860 let mock_server = MockServer :: start ( ) . await ;
18631861 Mock :: given ( method ( "POST" ) )
@@ -1898,17 +1896,13 @@ mod tests {
18981896 assert ! ( !resp. success) ;
18991897 assert ! ( resp. message_id. is_none( ) ) ;
19001898 let err = resp. error . expect ( "error should be set on send failure" ) ;
1901- assert ! (
1902- err. contains( "500" ) ,
1903- "error should include status code, got: {}" ,
1904- err
1905- ) ;
1899+ assert ! ( err. contains( "500" ) , "error should include status code, got: {}" , err) ;
19061900 }
19071901
19081902 #[ tokio:: test]
19091903 async fn handle_reply_empty_message_short_circuits ( ) {
1910- use wiremock:: matchers:: { method, path_regex} ;
19111904 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
1905+ use wiremock:: matchers:: { method, path_regex} ;
19121906
19131907 let mock_server = MockServer :: start ( ) . await ;
19141908 // Mount a mock that would fail the test if called
@@ -1945,10 +1939,7 @@ mod tests {
19451939 adapter. handle_reply ( & reply, & event_tx) . await ;
19461940
19471941 let received = event_rx. try_recv ( ) ;
1948- assert ! (
1949- received. is_ok( ) ,
1950- "expected failure GatewayResponse for empty message"
1951- ) ;
1942+ assert ! ( received. is_ok( ) , "expected failure GatewayResponse for empty message" ) ;
19521943 let resp: GatewayResponse = serde_json:: from_str ( & received. unwrap ( ) ) . unwrap ( ) ;
19531944 assert_eq ! ( resp. request_id, "req_empty" ) ;
19541945 assert ! ( !resp. success) ;
@@ -1957,8 +1948,8 @@ mod tests {
19571948
19581949 #[ tokio:: test]
19591950 async fn handle_reply_multi_chunk_failure_includes_error ( ) {
1960- use wiremock:: matchers:: { method, path_regex} ;
19611951 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
1952+ use wiremock:: matchers:: { method, path_regex} ;
19621953
19631954 let mock_server = MockServer :: start ( ) . await ;
19641955 Mock :: given ( method ( "POST" ) )
@@ -2039,16 +2030,15 @@ mod tests {
20392030
20402031 #[ tokio:: test]
20412032 async fn handle_reply_edit_message_does_not_send_response ( ) {
2042- use wiremock:: matchers:: { method, path_regex} ;
20432033 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
2034+ use wiremock:: matchers:: { method, path_regex} ;
20442035
20452036 let mock_server = MockServer :: start ( ) . await ;
20462037 Mock :: given ( method ( "PATCH" ) )
20472038 . and ( path_regex ( "/spaces/.*/messages/.*" ) )
2048- . respond_with (
2049- ResponseTemplate :: new ( 200 )
2050- . set_body_json ( serde_json:: json!( { "name" : "spaces/SP/messages/msg1" } ) ) ,
2051- )
2039+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json (
2040+ serde_json:: json!( { "name" : "spaces/SP/messages/msg1" } ) ,
2041+ ) )
20522042 . mount ( & mock_server)
20532043 . await ;
20542044
@@ -2083,16 +2073,15 @@ mod tests {
20832073
20842074 #[ tokio:: test]
20852075 async fn handle_reply_multi_chunk_sends_gateway_response ( ) {
2086- use wiremock:: matchers:: { method, path_regex} ;
20872076 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
2077+ use wiremock:: matchers:: { method, path_regex} ;
20882078
20892079 let mock_server = MockServer :: start ( ) . await ;
20902080 Mock :: given ( method ( "POST" ) )
20912081 . and ( path_regex ( "/spaces/.*/messages" ) )
2092- . respond_with (
2093- ResponseTemplate :: new ( 200 )
2094- . set_body_json ( serde_json:: json!( { "name" : "spaces/TEST/messages/first_chunk" } ) ) ,
2095- )
2082+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json (
2083+ serde_json:: json!( { "name" : "spaces/TEST/messages/first_chunk" } ) ,
2084+ ) )
20962085 . mount ( & mock_server)
20972086 . await ;
20982087
@@ -2127,28 +2116,24 @@ mod tests {
21272116 let resp: GatewayResponse = serde_json:: from_str ( & received. unwrap ( ) ) . unwrap ( ) ;
21282117 assert_eq ! ( resp. request_id, "req_multi" ) ;
21292118 assert ! ( resp. success) ;
2130- assert_eq ! (
2131- resp. message_id,
2132- Some ( "spaces/TEST/messages/first_chunk" . into( ) )
2133- ) ;
2119+ assert_eq ! ( resp. message_id, Some ( "spaces/TEST/messages/first_chunk" . into( ) ) ) ;
21342120 }
21352121
21362122 #[ tokio:: test]
21372123 async fn handle_reply_multi_chunk_partial_failure_reports_failure ( ) {
21382124 // Mixed success/failure: chunk 1 succeeds, subsequent chunks fail.
21392125 // Expect success=false (any chunk failure marks overall as failed),
21402126 // but message_id is still set so core has a reference.
2141- use wiremock:: matchers:: { method, path_regex} ;
21422127 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
2128+ use wiremock:: matchers:: { method, path_regex} ;
21432129
21442130 let mock_server = MockServer :: start ( ) . await ;
21452131 // First request: 200 OK with message name
21462132 Mock :: given ( method ( "POST" ) )
21472133 . and ( path_regex ( "/spaces/.*/messages" ) )
2148- . respond_with (
2149- ResponseTemplate :: new ( 200 )
2150- . set_body_json ( serde_json:: json!( { "name" : "spaces/TEST/messages/first_chunk" } ) ) ,
2151- )
2134+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json (
2135+ serde_json:: json!( { "name" : "spaces/TEST/messages/first_chunk" } ) ,
2136+ ) )
21522137 . up_to_n_times ( 1 )
21532138 . mount ( & mock_server)
21542139 . await ;
@@ -2190,10 +2175,7 @@ mod tests {
21902175 let resp: GatewayResponse = serde_json:: from_str ( & received. unwrap ( ) ) . unwrap ( ) ;
21912176 assert_eq ! ( resp. request_id, "req_partial" ) ;
21922177 assert ! ( !resp. success, "partial failure must report success=false" ) ;
2193- assert_eq ! (
2194- resp. message_id,
2195- Some ( "spaces/TEST/messages/first_chunk" . into( ) )
2196- ) ;
2178+ assert_eq ! ( resp. message_id, Some ( "spaces/TEST/messages/first_chunk" . into( ) ) ) ;
21972179 let err = resp. error . expect ( "partial failure should set error" ) ;
21982180 assert ! ( err. contains( "500" ) ) ;
21992181 }
0 commit comments