Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ impl Session {
let mut uid_message_ids: BTreeMap<u32, String> = BTreeMap::new();
uid_message_ids.insert(uid, rfc724_mid);
let (sender, receiver) = async_channel::unbounded();
self.fetch_many_msgs(context, folder, vec![uid], &uid_message_ids, sender)
.await?;
{
let _fetch_msgs_lock_guard = context.fetch_msgs_mutex.lock().await;
self.fetch_many_msgs(context, folder, vec![uid], &uid_message_ids, sender)
.await?;
}
if receiver.recv().await.is_err() {
bail!("Failed to fetch UID {uid}");
}
Expand Down
11 changes: 7 additions & 4 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,17 +1313,20 @@ async fn decide_chat_assignment(
..
} = &mime_parser.pre_message
{
let msg_id = rfc724_mid_exists(context, post_msg_rfc724_mid).await?;
if let Some(msg_id) = msg_id {
let post_msg_exists = if let Some((msg_id, not_downloaded)) =
message::rfc724_mid_exists_ex(context, post_msg_rfc724_mid, "download_state<>0").await?
{
context
.sql
.execute(
"UPDATE msgs SET pre_rfc724_mid=? WHERE id=?",
(rfc724_mid, msg_id),
)
.await?;
}
let post_msg_exists = msg_id.is_some();
!not_downloaded
} else {
false
};
info!(
context,
"Message {rfc724_mid} is a pre-message for {post_msg_rfc724_mid} (post_msg_exists:{post_msg_exists})."
Expand Down
6 changes: 6 additions & 0 deletions src/tests/pre_messages/receiving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ async fn test_receive_pre_message() -> Result<()> {
let msg = bob.recv_msg(&pre_message).await;
assert_eq!(msg.download_state, DownloadState::Available);
assert_summary_texts(&msg, bob, "👤 test").await;
let chat_id = msg.chat_id;

assert!(bob.recv_msg_opt(&pre_message).await.is_none());
let msg = Message::load_from_db(bob, msg.id).await?;
assert_eq!(msg.download_state, DownloadState::Available);
assert_summary_texts(&msg, bob, "👤 test").await;
assert_eq!(msg.chat_id, chat_id);
Ok(())
}

Expand Down
Loading