@@ -122,29 +122,29 @@ pub async fn webhook(
122122 let mut attachments = Vec :: new ( ) ;
123123 if is_photo || is_document || is_voice || is_audio {
124124 if let Some ( ref token) = state. telegram_bot_token {
125- let client = reqwest :: Client :: new ( ) ;
125+ let client = & state . client ;
126126 if is_photo {
127127 // Take the largest photo
128128 if let Some ( largest) = msg. photo . iter ( ) . max_by_key ( |p| p. width * p. height ) {
129129 if let Some ( att) =
130- download_telegram_media ( & client, token, & largest. file_id , "image" ) . await
130+ download_telegram_media ( client, token, & largest. file_id , "image" ) . await
131131 {
132132 attachments. push ( att) ;
133133 }
134134 }
135135 } else if let Some ( doc) = msg. document {
136136 let file_name = doc. file_name . unwrap_or_else ( || "unknown.txt" . to_string ( ) ) ;
137137 if let Some ( att) =
138- download_telegram_document ( & client, token, & doc. file_id , & file_name) . await
138+ download_telegram_document ( client, token, & doc. file_id , & file_name) . await
139139 {
140140 attachments. push ( att) ;
141141 }
142142 } else if let Some ( voice) = msg. voice {
143- if let Some ( att) = download_telegram_media ( & client, token, & voice. file_id , "audio" ) . await {
143+ if let Some ( att) = download_telegram_media ( client, token, & voice. file_id , "audio" ) . await {
144144 attachments. push ( att) ;
145145 }
146146 } else if let Some ( audio) = msg. audio {
147- if let Some ( att) = download_telegram_media ( & client, token, & audio. file_id , "audio" ) . await {
147+ if let Some ( att) = download_telegram_media ( client, token, & audio. file_id , "audio" ) . await {
148148 attachments. push ( att) ;
149149 }
150150 }
@@ -409,6 +409,7 @@ async fn download_telegram_media(
409409
410410 use base64:: Engine ;
411411 let b64_data = base64:: engine:: general_purpose:: STANDARD . encode ( & data_bytes) ;
412+ info ! ( file_id, size = data_bytes. len( ) , "Telegram {} download successful" , attachment_type) ;
412413
413414 Some ( Attachment {
414415 attachment_type : attachment_type. into ( ) ,
@@ -482,6 +483,7 @@ async fn download_telegram_document(
482483 let text = String :: from_utf8_lossy ( & bytes) ;
483484 use base64:: Engine ;
484485 let data = base64:: engine:: general_purpose:: STANDARD . encode ( text. as_bytes ( ) ) ;
486+ info ! ( file_id, file_name, size = bytes. len( ) , "Telegram document download successful" ) ;
485487
486488 Some ( Attachment {
487489 attachment_type : "text_file" . into ( ) ,
0 commit comments