From 916fab7d4b3555a3f649d8794d9a9e13ef2c6406 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 3 Apr 2020 12:12:56 +0300 Subject: [PATCH 1/2] hide_device_expired_messages: allow missing self or device chat --- src/chat.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 23c5a7725..e89a0561e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1620,8 +1620,12 @@ pub fn hide_device_expired_messages(context: &Context) -> Result { if let Some(delete_device_after) = context.get_config_delete_device_after() { let threshold_timestamp = time() - delete_device_after; - let self_chat_id = lookup_by_contact_id(context, DC_CONTACT_ID_SELF)?.0; - let device_chat_id = lookup_by_contact_id(context, DC_CONTACT_ID_DEVICE)?.0; + let self_chat_id = lookup_by_contact_id(context, DC_CONTACT_ID_SELF) + .unwrap_or_default() + .0; + let device_chat_id = lookup_by_contact_id(context, DC_CONTACT_ID_DEVICE) + .unwrap_or_default() + .0; // Hide expired messages // From 9c2a3b8a82bbd54de77809192e3897c2164d2fbb Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 3 Apr 2020 12:13:42 +0300 Subject: [PATCH 2/2] Chatlist::try_load: make hide_device_expired_messages errors non-fatal --- src/chatlist.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chatlist.rs b/src/chatlist.rs index 174c1a252..00380ed7f 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -94,7 +94,9 @@ impl Chatlist { ) -> Result { // Note that we do not emit DC_EVENT_MSGS_MODIFIED here even if some // messages get hidden to avoid reloading the same chatlist. - hide_device_expired_messages(context)?; + if let Err(err) = hide_device_expired_messages(context) { + warn!(context, "Failed to hide expired messages: {}", err); + } let mut add_archived_link_item = false;