mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
refactor: flatten lookup_chat_by_reply
This commit is contained in:
@@ -1408,7 +1408,10 @@ async fn lookup_chat_by_reply(
|
|||||||
) -> Result<Option<(ChatId, Blocked)>> {
|
) -> Result<Option<(ChatId, Blocked)>> {
|
||||||
// Try to assign message to the same chat as the parent message.
|
// Try to assign message to the same chat as the parent message.
|
||||||
|
|
||||||
if let Some(parent) = parent {
|
let Some(parent) = parent else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
|
||||||
let parent_chat = Chat::load_from_db(context, parent.chat_id).await?;
|
let parent_chat = Chat::load_from_db(context, parent.chat_id).await?;
|
||||||
|
|
||||||
if parent.download_state != DownloadState::Done
|
if parent.download_state != DownloadState::Done
|
||||||
@@ -1439,10 +1442,7 @@ async fn lookup_chat_by_reply(
|
|||||||
// If the parent chat is a 1:1 chat, and the sender is a classical MUA and added
|
// If the parent chat is a 1:1 chat, and the sender is a classical MUA and added
|
||||||
// a new person to TO/CC, then the message should not go to the 1:1 chat, but to a
|
// a new person to TO/CC, then the message should not go to the 1:1 chat, but to a
|
||||||
// newly created ad-hoc group.
|
// newly created ad-hoc group.
|
||||||
if parent_chat.typ == Chattype::Single
|
if parent_chat.typ == Chattype::Single && !mime_parser.has_chat_version() && to_ids.len() > 1 {
|
||||||
&& !mime_parser.has_chat_version()
|
|
||||||
&& to_ids.len() > 1
|
|
||||||
{
|
|
||||||
let mut chat_contacts = chat::get_chat_contacts(context, parent_chat.id).await?;
|
let mut chat_contacts = chat::get_chat_contacts(context, parent_chat.id).await?;
|
||||||
chat_contacts.push(ContactId::SELF);
|
chat_contacts.push(ContactId::SELF);
|
||||||
if to_ids.iter().any(|id| !chat_contacts.contains(id)) {
|
if to_ids.iter().any(|id| !chat_contacts.contains(id)) {
|
||||||
@@ -1454,10 +1454,7 @@ async fn lookup_chat_by_reply(
|
|||||||
context,
|
context,
|
||||||
"Assigning message to {} as it's a reply to {}.", parent_chat.id, parent.rfc724_mid
|
"Assigning message to {} as it's a reply to {}.", parent_chat.id, parent.rfc724_mid
|
||||||
);
|
);
|
||||||
return Ok(Some((parent_chat.id, parent_chat.blocked)));
|
Ok(Some((parent_chat.id, parent_chat.blocked)))
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this method returns true, the message shall be assigned to the 1:1 chat with the sender.
|
/// If this method returns true, the message shall be assigned to the 1:1 chat with the sender.
|
||||||
|
|||||||
Reference in New Issue
Block a user