@@ -14,7 +14,7 @@ use async_recursion::async_recursion;
1414use std:: io:: Seek ;
1515use rand:: RngCore ;
1616
17- use crate :: { aps:: get_message, ids:: { identity_manager:: { IDSSendMessage , MessageTarget , Raw } , CertifiedContext , IDSRecvMessage } , mmcs:: { self , put_authorize_body , AuthorizedOperation , MMCSReceipt , ReadContainer , WriteContainer } , util:: { base64_decode , base64_encode , bin_deserialize , bin_serialize , duration_since_epoch , plist_to_string , KeyedArchive , NSArray , NSArrayClass , NSDataClass , NSDictionary , NSDictionaryClass } , OSConfig } ;
17+ use crate :: { OSConfig , aps:: { get_message, new_aps_id } , ids:: { CertifiedContext , IDSRecvMessage , identity_manager:: { IDSSendMessage , MessageTarget , Raw } } , mmcs:: { self , AuthorizedOperation , MMCSReceipt , ReadContainer , WriteContainer , put_authorize_body } , util:: { KeyedArchive , NSArray , NSArrayClass , NSDataClass , NSDictionary , NSDictionaryClass , base64_decode , base64_encode , bin_deserialize , bin_serialize , duration_since_epoch , plist_to_string } } ;
1818
1919use crate :: { aps:: APSConnectionResource , error:: PushError , mmcs:: { get_mmcs, prepare_put, put_mmcs, MMCSConfig , Container , DataCacher , PreparedPut } , mmcsp, util:: { decode_hex, encode_hex, gzip, plist_to_bin, ungzip} } ;
2020
@@ -1161,7 +1161,7 @@ struct RequestMMCSUpload {
11611161 v : u64 ,
11621162 ua : String ,
11631163 c : u64 ,
1164- i : u32 ,
1164+ i : i32 ,
11651165 #[ serde( rename = "cV" ) ]
11661166 cv : u32 ,
11671167 #[ serde( rename = "cH" ) ]
@@ -1249,7 +1249,7 @@ impl MMCSFile {
12491249 let mut inputs = vec ! [ ( & prepared. mmcs, None , send_container) ] ;
12501250 let ( headers, body) = put_authorize_body ( & mmcs_config, & inputs) ;
12511251
1252- let msg_id = rand :: thread_rng ( ) . next_u32 ( ) ;
1252+ let msg_id = new_aps_id ( ) ;
12531253 let complete = RequestMMCSUpload {
12541254 c : 150 ,
12551255 ua : mmcs_config. mini_ua . clone ( ) ,
@@ -1261,9 +1261,8 @@ impl MMCSFile {
12611261 headers : format ! ( "{}\n " , headers. into_iter( ) . map( |( k, v) | format!( "{}:{}" , k, v) ) . collect:: <Vec <_>>( ) . join( "\n " ) ) ,
12621262 body : body. into ( )
12631263 } ;
1264- let binary = plist_to_bin ( & complete) ?;
12651264 let recv = apns. subscribe ( ) . await ;
1266- apns. send_message ( "com.apple.madrid" , binary , Some ( msg_id) ) . await ?;
1265+ apns. send_message ( "com.apple.madrid" , complete , Some ( msg_id) ) . await ?;
12671266
12681267 let reader = apns. wait_for_timeout ( recv, get_message ( |loaded| {
12691268 let Some ( c) = loaded. as_dictionary ( ) . unwrap ( ) . get ( "c" ) else {
@@ -1272,7 +1271,7 @@ impl MMCSFile {
12721271 let Some ( i) = loaded. as_dictionary ( ) . unwrap ( ) . get ( "i" ) else {
12731272 return None
12741273 } ;
1275- if c. as_unsigned_integer ( ) . unwrap ( ) == 150 && i. as_unsigned_integer ( ) . unwrap ( ) as u32 == msg_id {
1274+ if c. as_unsigned_integer ( ) . unwrap ( ) == 150 && i. as_signed_integer ( ) . unwrap ( ) as i32 == msg_id {
12761275 Some ( loaded)
12771276 } else { None }
12781277 } , & [ "com.apple.madrid" ] ) ) . await ?;
@@ -1311,7 +1310,7 @@ impl MMCSFile {
13111310 v : u64 ,
13121311 ua : String ,
13131312 c : u64 ,
1314- i : u32 ,
1313+ i : i32 ,
13151314 #[ serde( rename = "cH" ) ]
13161315 headers : String ,
13171316 #[ serde( rename = "mR" ) ]
@@ -1341,7 +1340,7 @@ impl MMCSFile {
13411340 let recieve_container = IMessageContainer :: new ( & self . key , writer, true ) ;
13421341
13431342 let domain = self . url . replace ( & format ! ( "/{}" , & self . object) , "" ) ;
1344- let msg_id = rand :: thread_rng ( ) . next_u32 ( ) ;
1343+ let msg_id = new_aps_id ( ) ;
13451344 let header = format ! ( "x-mme-client-info:{}" , mmcs_config. mme_client_info) ;
13461345 let request_download = RequestMMCSDownload {
13471346 object : self . object . to_string ( ) ,
@@ -1363,9 +1362,8 @@ impl MMCSFile {
13631362
13641363 info ! ( "mmcs obj {} sig {}" , self . object, encode_hex( & self . signature) ) ;
13651364
1366- let binary = plist_to_bin ( & request_download) ?;
13671365 let recv = apns. subscribe ( ) . await ;
1368- apns. send_message ( "com.apple.madrid" , binary , Some ( msg_id) ) . await ?;
1366+ apns. send_message ( "com.apple.madrid" , request_download , Some ( msg_id) ) . await ?;
13691367
13701368 let reader = apns. wait_for_timeout ( recv, get_message ( |loaded| {
13711369 let Some ( c) = loaded. as_dictionary ( ) . unwrap ( ) . get ( "c" ) else {
@@ -1374,7 +1372,7 @@ impl MMCSFile {
13741372 let Some ( i) = loaded. as_dictionary ( ) . unwrap ( ) . get ( "i" ) else {
13751373 return None
13761374 } ;
1377- if c. as_unsigned_integer ( ) . unwrap ( ) == 151 && i. as_unsigned_integer ( ) . unwrap ( ) as u32 == msg_id {
1375+ if c. as_unsigned_integer ( ) . unwrap ( ) == 151 && i. as_signed_integer ( ) . unwrap ( ) as i32 == msg_id {
13781376 Some ( loaded)
13791377 } else { None }
13801378 } , & [ "com.apple.madrid" ] ) ) . await ?;
0 commit comments