@@ -144,7 +144,7 @@ struct JoinedInvite {
144
144
/// On the other end, a bot will receive the message and make it available
145
145
/// to Delta Chat's developers.
146
146
pub 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 ? {
148
148
let last_sending_time = context. get_config_i64 ( Config :: LastStatisticsSent ) . await ?;
149
149
let next_sending_time = last_sending_time. saturating_add ( 30 ) ; // TODO increase to 1 day or 1 week
150
150
if next_sending_time <= time ( ) {
@@ -154,6 +154,21 @@ pub async fn maybe_send_statistics(context: &Context) -> Result<Option<ChatId>>
154
154
Ok ( None )
155
155
}
156
156
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
+
157
172
async fn send_statistics ( context : & Context ) -> Result < ChatId > {
158
173
info ! ( context, "Sending statistics." ) ;
159
174
@@ -584,7 +599,7 @@ pub(crate) async fn count_securejoin_ux_info(
584
599
source : Option < u32 > ,
585
600
uipath : Option < u32 > ,
586
601
) -> Result < ( ) > {
587
- if !context . get_config_bool ( Config :: SendStatistics ) . await ? {
602
+ if !should_send_statistics ( context ) . await ? {
588
603
return Ok ( ( ) ) ;
589
604
}
590
605
@@ -669,7 +684,7 @@ async fn get_securejoin_uipath_stats(context: &Context) -> Result<SecurejoinUIPa
669
684
}
670
685
671
686
pub ( 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 ? {
673
688
return Ok ( ( ) ) ;
674
689
}
675
690
0 commit comments