From 212fbc125cb6fb100d31a9b66442370171daab48 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Tue, 5 Sep 2023 21:38:41 -0300 Subject: [PATCH] fix: ChatId::parent_query(): Don't filter out OutPending and OutFailed messages The new message for which `parent_query()` is done may assume that it will be received in a context affected by those messages, e.g. they could add new members to a group and the new message will contain them in "To:". Anyway recipients must be prepared to orphaned references. --- src/chat.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 9baa7fdb1..306985cbd 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1040,7 +1040,7 @@ impl ChatId { let sql = &context.sql; let query = format!( "SELECT {fields} \ - FROM msgs WHERE chat_id=? AND state NOT IN (?, ?, ?, ?) AND NOT hidden \ + FROM msgs WHERE chat_id=? AND state NOT IN (?, ?) AND NOT hidden \ ORDER BY timestamp DESC, id DESC \ LIMIT 1;" ); @@ -1051,8 +1051,11 @@ impl ChatId { self, MessageState::OutPreparing, MessageState::OutDraft, - MessageState::OutPending, - MessageState::OutFailed, + // We don't filter `OutPending` and `OutFailed` messages because the new message + // for which `parent_query()` is done may assume that it will be received in a + // context affected by those messages, e.g. they could add new members to a + // group and the new message will contain them in "To:". Anyway recipients must + // be prepared to orphaned references. ), f, )