mirror of
https://github.com/chatmail/core.git
synced 2026-09-22 13:01:21 +03:00
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
This commit is contained in:
@@ -1448,10 +1448,7 @@ impl MessageState {
|
|||||||
/// Returns true if the message can transition to `OutFailed` state from the current state.
|
/// Returns true if the message can transition to `OutFailed` state from the current state.
|
||||||
pub fn can_fail(self) -> bool {
|
pub fn can_fail(self) -> bool {
|
||||||
use MessageState::*;
|
use MessageState::*;
|
||||||
matches!(
|
matches!(self, OutPending | OutDelivered)
|
||||||
self,
|
|
||||||
OutPending | OutDelivered | OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true for any outgoing message states.
|
/// Returns true for any outgoing message states.
|
||||||
|
|||||||
@@ -760,3 +760,23 @@ async fn test_get_existing_msg_ids() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user