mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
fix: Downgrade message state to InNoticed when it's fully downloaded (#2970)
This commit is contained in:
@@ -2618,12 +2618,29 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
alice.set_config(Config::DownloadLimit, None).await?;
|
alice.set_config(Config::DownloadLimit, None).await?;
|
||||||
let msg = alice.recv_msg(&sent_msg).await;
|
// Simulate that the message is even marked as `\Seen` on IMAP.
|
||||||
|
let rcvd_msg = receive_imf(alice, sent_msg.payload().as_bytes(), true)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(rcvd_msg.chat_id, msg.chat_id);
|
||||||
|
let msg = Message::load_from_db(alice, *rcvd_msg.msg_ids.last().unwrap())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
assert_eq!(msg.download_state, DownloadState::Done);
|
assert_eq!(msg.download_state, DownloadState::Done);
|
||||||
assert!(msg.param.get_bool(Param::WantsMdn).unwrap_or_default());
|
assert!(msg.param.get_bool(Param::WantsMdn).unwrap_or_default());
|
||||||
assert!(msg.get_showpadlock());
|
assert!(msg.get_showpadlock());
|
||||||
|
assert_eq!(msg.state, MessageState::InNoticed);
|
||||||
|
markseen_msgs(alice, vec![msg.id]).await?;
|
||||||
|
let msg = Message::load_from_db(alice, msg.id).await?;
|
||||||
assert_eq!(msg.state, MessageState::InSeen);
|
assert_eq!(msg.state, MessageState::InSeen);
|
||||||
|
assert_eq!(
|
||||||
|
alice
|
||||||
|
.sql
|
||||||
|
.count("SELECT COUNT(*) FROM smtp_mdns", ())
|
||||||
|
.await?,
|
||||||
|
1
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1014,13 +1014,15 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state = if seen
|
state = if (seen && replace_msg_id.is_none())
|
||||||
|| fetching_existing_messages
|
|| fetching_existing_messages
|
||||||
|| is_mdn
|
|| is_mdn
|
||||||
|| is_reaction
|
|| is_reaction
|
||||||
|| chat_id_blocked == Blocked::Yes
|
|| chat_id_blocked == Blocked::Yes
|
||||||
{
|
{
|
||||||
MessageState::InSeen
|
MessageState::InSeen
|
||||||
|
} else if seen {
|
||||||
|
MessageState::InNoticed
|
||||||
} else {
|
} else {
|
||||||
MessageState::InFresh
|
MessageState::InFresh
|
||||||
};
|
};
|
||||||
@@ -1562,7 +1564,7 @@ INSERT INTO msgs
|
|||||||
ON CONFLICT (id) DO UPDATE
|
ON CONFLICT (id) DO UPDATE
|
||||||
SET rfc724_mid=excluded.rfc724_mid, chat_id=excluded.chat_id,
|
SET rfc724_mid=excluded.rfc724_mid, chat_id=excluded.chat_id,
|
||||||
from_id=excluded.from_id, to_id=excluded.to_id, timestamp_sent=excluded.timestamp_sent,
|
from_id=excluded.from_id, to_id=excluded.to_id, timestamp_sent=excluded.timestamp_sent,
|
||||||
type=excluded.type, msgrmsg=excluded.msgrmsg,
|
type=excluded.type, state=min(state,max(?,13)), msgrmsg=excluded.msgrmsg,
|
||||||
txt=excluded.txt, txt_normalized=excluded.txt_normalized, subject=excluded.subject,
|
txt=excluded.txt, txt_normalized=excluded.txt_normalized, subject=excluded.subject,
|
||||||
txt_raw=excluded.txt_raw, param=excluded.param,
|
txt_raw=excluded.txt_raw, param=excluded.param,
|
||||||
hidden=excluded.hidden,bytes=excluded.bytes, mime_headers=excluded.mime_headers,
|
hidden=excluded.hidden,bytes=excluded.bytes, mime_headers=excluded.mime_headers,
|
||||||
@@ -1613,7 +1615,8 @@ RETURNING id
|
|||||||
} else {
|
} else {
|
||||||
DownloadState::Done
|
DownloadState::Done
|
||||||
},
|
},
|
||||||
mime_parser.hop_info
|
mime_parser.hop_info,
|
||||||
|
state,
|
||||||
],
|
],
|
||||||
|row| {
|
|row| {
|
||||||
let msg_id: MsgId = row.get(0)?;
|
let msg_id: MsgId = row.get(0)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user