From f656cb29be8ac23f854859c13e70109009441f63 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 30 Sep 2023 23:22:19 +0000 Subject: [PATCH] fix: ignore special chats in get_similar_chat_ids() For unknown reason trash chat contains members in some existing databases. Workaround this by ignoring chats_contacts entries with special chat_id. --- src/chat.rs | 5 +++-- src/contact.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 378456819..c131fd1e9 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -918,9 +918,10 @@ impl ChatId { .sql .query_map( "SELECT chat_id, count(*) AS n - FROM chats_contacts where contact_id > 9 + FROM chats_contacts + WHERE contact_id > ? AND chat_id > ? GROUP BY chat_id", - (), + (ContactId::LAST_SPECIAL, DC_CHAT_ID_LAST_SPECIAL), |row| { let chat_id: ChatId = row.get(0)?; let size: f64 = row.get(1)?; diff --git a/src/contact.rs b/src/contact.rs index 2af80c147..e57fc39bf 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -109,7 +109,7 @@ impl ContactId { /// ID of the contact for device messages. pub const DEVICE: ContactId = ContactId::new(5); - const LAST_SPECIAL: ContactId = ContactId::new(9); + pub(crate) const LAST_SPECIAL: ContactId = ContactId::new(9); /// Address to go with [`ContactId::DEVICE`]. ///