Skip to content

Commit

Permalink
fix: return correct MsgId for malformed message tombstone
Browse files Browse the repository at this point in the history
.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.
  • Loading branch information
link2xt committed Nov 28, 2023
1 parent 4332170 commit 37d2aaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
7 changes: 6 additions & 1 deletion src/receive_imf/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]\n\
Expand All @@ -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());
Expand Down

0 comments on commit 37d2aaf

Please sign in to comment.