From b766a9a8fa9ed5ed73b5ac92b54a555d147f12fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?bi=C3=B8rn?= Date: Mon, 21 Sep 2026 19:04:57 +0200 Subject: [PATCH] feat: do not mark message as failed for which we got a read receipt before this PR avoids marking a message as being failed if we already received an read receipt for it. background: esp. with multi relay it will easily happen that we get some NDN for some relays. this does not mean the message at a whole was failing, esp. if we got a read receipt (MDN) before with https://github.com/chatmail/core/pull/8722 we do no longer process NDN in groups, so the change of this PR affects one-to-one chats only --- src/message.rs | 5 +---- src/message/message_tests.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/message.rs b/src/message.rs index abb39aaa0..d1c058a3e 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1448,10 +1448,7 @@ impl MessageState { /// Returns true if the message can transition to `OutFailed` state from the current state. pub fn can_fail(self) -> bool { use MessageState::*; - matches!( - self, - OutPending | OutDelivered | OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed. - ) + matches!(self, OutPending | OutDelivered) } /// Returns true for any outgoing message states. diff --git a/src/message/message_tests.rs b/src/message/message_tests.rs index f74d98b58..41c579d4e 100644 --- a/src/message/message_tests.rs +++ b/src/message/message_tests.rs @@ -760,3 +760,23 @@ async fn test_get_existing_msg_ids() -> Result<()> { Ok(()) } + +#[test] +fn test_can_fail() -> Result<()> { + use MessageState::*; + + // states that are not allowed to transition to OutFailed + assert!(!Undefined.can_fail()); + assert!(!InFresh.can_fail()); + assert!(!InNoticed.can_fail()); + assert!(!InSeen.can_fail()); + assert!(!OutDraft.can_fail()); + assert!(!OutFailed.can_fail()); + assert!(!OutMdnRcvd.can_fail()); + + // states that are allowed to transition to OutFailed + assert!(OutPending.can_fail()); + assert!(OutDelivered.can_fail()); + + Ok(()) +}