@@ -144,7 +144,7 @@ struct JoinedInvite {
144144/// On the other end, a bot will receive the message and make it available 
145145/// to Delta Chat's developers. 
146146pub  async  fn  maybe_send_statistics ( context :  & Context )  -> Result < Option < ChatId > >  { 
147-     if  context . get_config_bool ( Config :: SendStatistics ) . await ? { 
147+     if  should_send_statistics ( context ) . await ? { 
148148        let  last_sending_time = context. get_config_i64 ( Config :: LastStatisticsSent ) . await ?; 
149149        let  next_sending_time = last_sending_time. saturating_add ( 30 ) ;  // TODO increase to 1 day or 1 week 
150150        if  next_sending_time <= time ( )  { 
@@ -154,6 +154,21 @@ pub async fn maybe_send_statistics(context: &Context) -> Result<Option<ChatId>>
154154    Ok ( None ) 
155155} 
156156
157+ pub ( crate )  async  fn  should_send_statistics ( _context :  & Context )  -> Result < bool >  { 
158+     #[ cfg( any( target_os = "android" ,  test) ) ]  
159+     { 
160+         _context. get_config_bool ( Config :: SendStatistics ) . await 
161+     } 
162+ 
163+     // If the user enables statistics-sending on Android, 
164+     // and then transfers the account to e.g. Desktop, 
165+     // we should not send any statistics: 
166+     #[ cfg( not( any( target_os = "android" ,  test) ) ) ]  
167+     { 
168+         Ok ( false ) 
169+     } 
170+ } 
171+ 
157172async  fn  send_statistics ( context :  & Context )  -> Result < ChatId >  { 
158173    info ! ( context,  "Sending statistics." ) ; 
159174
@@ -584,7 +599,7 @@ pub(crate) async fn count_securejoin_ux_info(
584599    source :  Option < u32 > , 
585600    uipath :  Option < u32 > , 
586601)  -> Result < ( ) >  { 
587-     if  !context . get_config_bool ( Config :: SendStatistics ) . await ? { 
602+     if  !should_send_statistics ( context ) . await ? { 
588603        return  Ok ( ( ) ) ; 
589604    } 
590605
@@ -669,7 +684,7 @@ async fn get_securejoin_uipath_stats(context: &Context) -> Result<SecurejoinUIPa
669684} 
670685
671686pub ( crate )  async  fn  count_securejoin_invite ( context :  & Context ,  invite :  & QrInvite )  -> Result < ( ) >  { 
672-     if  !context . get_config_bool ( Config :: SendStatistics ) . await ? { 
687+     if  !should_send_statistics ( context ) . await ? { 
673688        return  Ok ( ( ) ) ; 
674689    } 
675690
0 commit comments