fix: return correct MsgId for malformed message tombstone

.execute() returns the number of affected rows,
in this case it is always 1 and MsgId(1) is returned
instead of the actual tombstone row ID.
This commit is contained in:
link2xt
2023-11-28 21:24:52 +00:00
parent 4332170691
commit 37d2aafb26
2 changed files with 7 additions and 2 deletions

View File

@@ -139,7 +139,7 @@ pub(crate) async fn receive_imf_inner(
let row_id = context
.sql
.execute(
.insert(
"INSERT INTO msgs(rfc724_mid, chat_id) VALUES (?,?)",
(rfc724_mid, DC_CHAT_ID_TRASH),
)

View File

@@ -322,7 +322,7 @@ async fn test_no_from() {
let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap();
assert!(chats.get_msg_id(0).is_err());
receive_imf(
let received = receive_imf(
context,
b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\
To: bob@example.com\n\
@@ -335,8 +335,13 @@ async fn test_no_from() {
false,
)
.await
.unwrap()
.unwrap();
// Check that tombstone MsgId is returned.
assert_eq!(received.msg_ids.len(), 1);
assert!(!received.msg_ids[0].is_special());
let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap();
// Check that the message is not shown to the user:
assert!(chats.is_empty());