mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
- move CC-parsing next to To-parsing where it blongs
- pass to_ids and from_id as immutable to add_parts
This commit is contained in:
@@ -120,14 +120,13 @@ pub fn dc_receive_imf(
|
|||||||
if from_ids.len() > 1 {
|
if from_ids.len() > 1 {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"mail has more than one address in From: {:?}", field_from
|
"mail has more than one From address, only using first: {:?}", field_from
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if from_ids.contains(&DC_CONTACT_ID_SELF) {
|
if from_ids.contains(&DC_CONTACT_ID_SELF) {
|
||||||
incoming = false;
|
incoming = false;
|
||||||
if to_ids.len() == 1 && to_ids.contains(&DC_CONTACT_ID_SELF) {
|
from_id = DC_CONTACT_ID_SELF;
|
||||||
from_id = DC_CONTACT_ID_SELF;
|
incoming_origin = Origin::OutgoingBcc;
|
||||||
}
|
|
||||||
} else if !from_ids.is_empty() {
|
} else if !from_ids.is_empty() {
|
||||||
from_id = from_ids.get_index(0).cloned().unwrap_or_default();
|
from_id = from_ids.get_index(0).cloned().unwrap_or_default();
|
||||||
incoming_origin = Contact::get_origin_by_id(context, from_id, &mut from_id_blocked)
|
incoming_origin = Contact::get_origin_by_id(context, from_id, &mut from_id_blocked)
|
||||||
@@ -139,20 +138,21 @@ pub fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure, to_ids starts with the first To:-address (Cc: is added in the loop below pass)
|
for header_def in vec![HeaderDef::To, HeaderDef::Cc] {
|
||||||
if let Some(field) = mime_parser.get(HeaderDef::To) {
|
if let Some(field) = mime_parser.get(header_def) {
|
||||||
dc_add_or_lookup_contacts_by_address_list(
|
dc_add_or_lookup_contacts_by_address_list(
|
||||||
context,
|
context,
|
||||||
&field,
|
&field,
|
||||||
if !incoming {
|
if !incoming {
|
||||||
Origin::OutgoingTo
|
Origin::OutgoingTo
|
||||||
} else if incoming_origin.is_verified() {
|
} else if incoming_origin.is_verified() {
|
||||||
Origin::IncomingTo
|
Origin::IncomingTo
|
||||||
} else {
|
} else {
|
||||||
Origin::IncomingUnknownTo
|
Origin::IncomingUnknownTo
|
||||||
},
|
},
|
||||||
&mut to_ids,
|
&mut to_ids,
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add parts
|
// Add parts
|
||||||
@@ -180,10 +180,10 @@ pub fn dc_receive_imf(
|
|||||||
&mut incoming_origin,
|
&mut incoming_origin,
|
||||||
server_folder.as_ref(),
|
server_folder.as_ref(),
|
||||||
server_uid,
|
server_uid,
|
||||||
&mut to_ids,
|
&to_ids,
|
||||||
&rfc724_mid,
|
&rfc724_mid,
|
||||||
&mut sent_timestamp,
|
&mut sent_timestamp,
|
||||||
&mut from_id,
|
from_id,
|
||||||
from_id_blocked,
|
from_id_blocked,
|
||||||
&mut hidden,
|
&mut hidden,
|
||||||
&mut chat_id,
|
&mut chat_id,
|
||||||
@@ -260,10 +260,10 @@ fn add_parts(
|
|||||||
incoming_origin: &mut Origin,
|
incoming_origin: &mut Origin,
|
||||||
server_folder: impl AsRef<str>,
|
server_folder: impl AsRef<str>,
|
||||||
server_uid: u32,
|
server_uid: u32,
|
||||||
to_ids: &mut ContactIds,
|
to_ids: &ContactIds,
|
||||||
rfc724_mid: &str,
|
rfc724_mid: &str,
|
||||||
sent_timestamp: &mut i64,
|
sent_timestamp: &mut i64,
|
||||||
from_id: &mut u32,
|
from_id: u32,
|
||||||
from_id_blocked: bool,
|
from_id_blocked: bool,
|
||||||
hidden: &mut bool,
|
hidden: &mut bool,
|
||||||
chat_id: &mut u32,
|
chat_id: &mut u32,
|
||||||
@@ -282,24 +282,6 @@ fn add_parts(
|
|||||||
let mut mime_in_reply_to = String::new();
|
let mut mime_in_reply_to = String::new();
|
||||||
let mut mime_references = String::new();
|
let mut mime_references = String::new();
|
||||||
|
|
||||||
// collect the rest information, CC: is added to the to-list, BCC: is ignored
|
|
||||||
// (we should not add BCC to groups as this would split groups. We could add them as "known contacts",
|
|
||||||
// however, the benefit is very small and this may leak data that is expected to be hidden)
|
|
||||||
if let Some(fld_cc) = mime_parser.get(HeaderDef::Cc) {
|
|
||||||
dc_add_or_lookup_contacts_by_address_list(
|
|
||||||
context,
|
|
||||||
fld_cc,
|
|
||||||
if !incoming {
|
|
||||||
Origin::OutgoingCc
|
|
||||||
} else if incoming_origin.is_verified() {
|
|
||||||
Origin::IncomingCc
|
|
||||||
} else {
|
|
||||||
Origin::IncomingUnknownCc
|
|
||||||
},
|
|
||||||
to_ids,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check, if the mail is already in our database - if so, just update the folder/uid
|
// check, if the mail is already in our database - if so, just update the folder/uid
|
||||||
// (if the mail was moved around) and finish. (we may get a mail twice eg. if it is
|
// (if the mail was moved around) and finish. (we may get a mail twice eg. if it is
|
||||||
// moved between folders. make sure, this check is done eg. before securejoin-processing) */
|
// moved between folders. make sure, this check is done eg. before securejoin-processing) */
|
||||||
@@ -354,7 +336,7 @@ fn add_parts(
|
|||||||
msgrmsg = 1;
|
msgrmsg = 1;
|
||||||
*chat_id = 0;
|
*chat_id = 0;
|
||||||
allow_creation = true;
|
allow_creation = true;
|
||||||
match handle_securejoin_handshake(context, mime_parser, *from_id) {
|
match handle_securejoin_handshake(context, mime_parser, from_id) {
|
||||||
Ok(ret) => {
|
Ok(ret) => {
|
||||||
if ret.hide_this_msg {
|
if ret.hide_this_msg {
|
||||||
*hidden = true;
|
*hidden = true;
|
||||||
@@ -376,7 +358,7 @@ fn add_parts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (test_normal_chat_id, test_normal_chat_id_blocked) =
|
let (test_normal_chat_id, test_normal_chat_id_blocked) =
|
||||||
chat::lookup_by_contact_id(context, *from_id).unwrap_or_default();
|
chat::lookup_by_contact_id(context, from_id).unwrap_or_default();
|
||||||
|
|
||||||
// get the chat_id - a chat_id here is no indicator that the chat is displayed in the normal list,
|
// get the chat_id - a chat_id here is no indicator that the chat is displayed in the normal list,
|
||||||
// it might also be blocked and displayed in the deaddrop as a result
|
// it might also be blocked and displayed in the deaddrop as a result
|
||||||
@@ -396,7 +378,7 @@ fn add_parts(
|
|||||||
&mut mime_parser,
|
&mut mime_parser,
|
||||||
allow_creation,
|
allow_creation,
|
||||||
create_blocked,
|
create_blocked,
|
||||||
*from_id,
|
from_id,
|
||||||
to_ids,
|
to_ids,
|
||||||
)?;
|
)?;
|
||||||
*chat_id = new_chat_id;
|
*chat_id = new_chat_id;
|
||||||
@@ -417,7 +399,7 @@ fn add_parts(
|
|||||||
|
|
||||||
if *chat_id == 0 {
|
if *chat_id == 0 {
|
||||||
// try to create a normal chat
|
// try to create a normal chat
|
||||||
let create_blocked = if *from_id == *to_id {
|
let create_blocked = if from_id == *to_id {
|
||||||
Blocked::Not
|
Blocked::Not
|
||||||
} else {
|
} else {
|
||||||
Blocked::Deaddrop
|
Blocked::Deaddrop
|
||||||
@@ -428,7 +410,7 @@ fn add_parts(
|
|||||||
chat_id_blocked = test_normal_chat_id_blocked;
|
chat_id_blocked = test_normal_chat_id_blocked;
|
||||||
} else if allow_creation {
|
} else if allow_creation {
|
||||||
let (id, bl) =
|
let (id, bl) =
|
||||||
chat::create_or_lookup_by_contact_id(context, *from_id, create_blocked)
|
chat::create_or_lookup_by_contact_id(context, from_id, create_blocked)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
*chat_id = id;
|
*chat_id = id;
|
||||||
chat_id_blocked = bl;
|
chat_id_blocked = bl;
|
||||||
@@ -440,7 +422,7 @@ fn add_parts(
|
|||||||
} else if is_reply_to_known_message(context, mime_parser) {
|
} else if is_reply_to_known_message(context, mime_parser) {
|
||||||
// we do not want any chat to be created implicitly. Because of the origin-scale-up,
|
// we do not want any chat to be created implicitly. Because of the origin-scale-up,
|
||||||
// the contact requests will pop up and this should be just fine.
|
// the contact requests will pop up and this should be just fine.
|
||||||
Contact::scaleup_origin_by_id(context, *from_id, Origin::IncomingReplyTo);
|
Contact::scaleup_origin_by_id(context, from_id, Origin::IncomingReplyTo);
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
"Message is a reply to a known message, mark sender as known.",
|
"Message is a reply to a known message, mark sender as known.",
|
||||||
@@ -480,7 +462,6 @@ fn add_parts(
|
|||||||
// the mail is on the IMAP server, probably it is also delivered.
|
// the mail is on the IMAP server, probably it is also delivered.
|
||||||
// We cannot recreate other states (read, error).
|
// We cannot recreate other states (read, error).
|
||||||
state = MessageState::OutDelivered;
|
state = MessageState::OutDelivered;
|
||||||
*from_id = DC_CONTACT_ID_SELF;
|
|
||||||
if !to_ids.is_empty() {
|
if !to_ids.is_empty() {
|
||||||
*to_id = to_ids.get_index(0).cloned().unwrap_or_default();
|
*to_id = to_ids.get_index(0).cloned().unwrap_or_default();
|
||||||
if *chat_id == 0 {
|
if *chat_id == 0 {
|
||||||
@@ -489,7 +470,7 @@ fn add_parts(
|
|||||||
&mut mime_parser,
|
&mut mime_parser,
|
||||||
allow_creation,
|
allow_creation,
|
||||||
Blocked::Not,
|
Blocked::Not,
|
||||||
*from_id,
|
from_id,
|
||||||
to_ids,
|
to_ids,
|
||||||
)?;
|
)?;
|
||||||
*chat_id = new_chat_id;
|
*chat_id = new_chat_id;
|
||||||
@@ -521,7 +502,7 @@ fn add_parts(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let self_sent = *from_id == DC_CONTACT_ID_SELF
|
let self_sent = from_id == DC_CONTACT_ID_SELF
|
||||||
&& to_ids.len() == 1
|
&& to_ids.len() == 1
|
||||||
&& to_ids.contains(&DC_CONTACT_ID_SELF);
|
&& to_ids.contains(&DC_CONTACT_ID_SELF);
|
||||||
|
|
||||||
@@ -548,7 +529,7 @@ fn add_parts(
|
|||||||
calc_timestamps(
|
calc_timestamps(
|
||||||
context,
|
context,
|
||||||
*chat_id,
|
*chat_id,
|
||||||
*from_id,
|
from_id,
|
||||||
*sent_timestamp,
|
*sent_timestamp,
|
||||||
0 == flags & DC_IMAP_SEEN,
|
0 == flags & DC_IMAP_SEEN,
|
||||||
&mut sort_timestamp,
|
&mut sort_timestamp,
|
||||||
@@ -612,7 +593,7 @@ fn add_parts(
|
|||||||
server_folder.as_ref(),
|
server_folder.as_ref(),
|
||||||
server_uid as i32,
|
server_uid as i32,
|
||||||
*chat_id as i32,
|
*chat_id as i32,
|
||||||
*from_id as i32,
|
from_id as i32,
|
||||||
*to_id as i32,
|
*to_id as i32,
|
||||||
sort_timestamp,
|
sort_timestamp,
|
||||||
*sent_timestamp,
|
*sent_timestamp,
|
||||||
|
|||||||
Reference in New Issue
Block a user