From 910d2c34655bf6a903483028ae38361378cd52ee Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Sun, 17 Mar 2024 17:21:52 +0100 Subject: [PATCH] Workaround UUID not found errors (#243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This just ignores those errors when sending to a group. Ideally, this should mark such contacts as unregistered and not send messages to them anymore. But the store does not yet have the capability to do that. Related to #110. --------- Co-authored-by: Gabriel FĂ©ron --- presage/src/manager/registered.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/presage/src/manager/registered.rs b/presage/src/manager/registered.rs index 1f5b3d9c8..e2301a9c4 100644 --- a/presage/src/manager/registered.rs +++ b/presage/src/manager/registered.rs @@ -12,7 +12,7 @@ use libsignal_service::groups_v2::{decrypt_group, Group, GroupsManager, InMemory use libsignal_service::messagepipe::{Incoming, MessagePipe, ServiceCredentials}; use libsignal_service::models::Contact; use libsignal_service::prelude::phonenumber::PhoneNumber; -use libsignal_service::prelude::{ProtobufMessage, Uuid}; +use libsignal_service::prelude::{MessageSenderError, ProtobufMessage, Uuid}; use libsignal_service::profile_cipher::ProfileCipher; use libsignal_service::proto::data_message::Delete; use libsignal_service::proto::{ @@ -961,8 +961,20 @@ impl Manager { .send_message_to_group(recipients, content_body.clone(), timestamp, online_only) .await; - // return first error if any - results.into_iter().find(|res| res.is_err()).transpose()?; + // TODO: Handle the NotFound error in the future by removing all sessions to this UUID and marking it as unregistered, not sending any messages to this contact anymore. + results + .into_iter() + .find(|res| match res { + Ok(_) => false, + // Ignore any NotFound errors, those mean that e.g. some contact in a group deleted his account. + Err(MessageSenderError::NotFound { uuid }) => { + debug!("UUID {uuid} not found, skipping sent message result"); + false + } + // return first error if any + Err(_) => true, + }) + .transpose()?; let content = Content { metadata: Metadata {