From bb47299ee4e3ccaf37e838c329c48931e1fe0c43 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Tue, 9 Jan 2024 14:30:29 -0300 Subject: [PATCH] fix: contact::set_blocked(): Don't fail on sync errors, just log them Multi-device synchronisation is not critical and should not fail the local operation, in other places sync errors are already ignored. --- src/chat.rs | 2 +- src/contact.rs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 4a3f8f9b4..832d4b369 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2104,7 +2104,7 @@ impl Chat { } } -async fn sync(context: &Context, id: SyncId, action: SyncAction) -> Result<()> { +pub(crate) async fn sync(context: &Context, id: SyncId, action: SyncAction) -> Result<()> { context .add_sync_item(SyncData::AlterChat { id, action }) .await?; diff --git a/src/contact.rs b/src/contact.rs index cc4a55bad..6e8dfface 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -26,13 +26,14 @@ use crate::constants::{Blocked, Chattype, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY} use crate::context::Context; use crate::events::EventType; use crate::key::{load_self_public_key, DcKey}; +use crate::log::LogExt; use crate::login_param::LoginParam; use crate::message::MessageState; use crate::mimeparser::AvatarAction; use crate::param::{Param, Params}; use crate::peerstate::Peerstate; use crate::sql::{self, params_iter}; -use crate::sync::{self, Sync::*, SyncData}; +use crate::sync::{self, Sync::*}; use crate::tools::{ duration_to_str, get_abs_path, improve_single_line_input, strip_rtlo_characters, time, EmailAddress, @@ -1497,13 +1498,14 @@ WHERE type=? AND id IN ( true => chat::SyncAction::Block, false => chat::SyncAction::Unblock, }; - context - .add_sync_item(SyncData::AlterChat { - id: chat::SyncId::ContactAddr(contact.addr.clone()), - action, - }) - .await?; - context.send_sync_msg().await?; + chat::sync( + context, + chat::SyncId::ContactAddr(contact.addr.clone()), + action, + ) + .await + .log_err(context) + .ok(); } }