From e4bab62dbe8732d7a04d3964d83fe6e5b65e6758 Mon Sep 17 00:00:00 2001 From: boxdot Date: Tue, 14 Nov 2023 17:34:09 +0100 Subject: [PATCH] fix: invalid warning about sync claim --- libsignal-service/src/sender.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libsignal-service/src/sender.rs b/libsignal-service/src/sender.rs index 9e0185c7a..bb5183a68 100644 --- a/libsignal-service/src/sender.rs +++ b/libsignal-service/src/sender.rs @@ -380,25 +380,26 @@ where results.push(result); } - if needs_sync_in_results != message.is_some() { + if needs_sync_in_results && message.is_none() { // XXX: does this happen? log::warn!("Server claims need sync, but not sending datamessage."); } // we only need to send a synchronization message once if let Some(message) = message { - let sub_device_count = match self + let is_multi_device = self .protocol_store .get_sub_device_sessions(&self.local_address) .await - { - Ok(x) => x.len(), - Err(e) => { - log::error!("Attempt to count local subdevices failed; assuming zero: {}", e); - 0 - }, - }; - if needs_sync_in_results || sub_device_count > 0 { + .map(|sessions| !sessions.is_empty()) + .unwrap_or_else(|e| { + log::error!( + "Attempt to count local subdevices failed; \ + assuming zero: {e}" + ); + false + }); + if needs_sync_in_results || is_multi_device { let sync_message = self .create_multi_device_sent_transcript_content( None,