mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
another reverse mut bites the dust
This commit is contained in:
@@ -71,8 +71,6 @@ pub fn dc_receive_imf(
|
|||||||
let mut created_db_entries = Vec::new();
|
let mut created_db_entries = Vec::new();
|
||||||
let mut create_event_to_send = Some(CreateEvent::MsgsChanged);
|
let mut create_event_to_send = Some(CreateEvent::MsgsChanged);
|
||||||
|
|
||||||
let mut to_ids = ContactIds::new();
|
|
||||||
|
|
||||||
// helper method to handle early exit and memory cleanup
|
// helper method to handle early exit and memory cleanup
|
||||||
let cleanup = |context: &Context,
|
let cleanup = |context: &Context,
|
||||||
create_event_to_send: &Option<CreateEvent>,
|
create_event_to_send: &Option<CreateEvent>,
|
||||||
@@ -109,12 +107,10 @@ pub fn dc_receive_imf(
|
|||||||
let mut incoming_origin = Origin::Unknown;
|
let mut incoming_origin = Origin::Unknown;
|
||||||
|
|
||||||
if let Some(field_from) = mime_parser.get(HeaderDef::From_) {
|
if let Some(field_from) = mime_parser.get(HeaderDef::From_) {
|
||||||
let mut from_ids = ContactIds::new();
|
let from_ids = dc_add_or_lookup_contacts_by_address_list(
|
||||||
dc_add_or_lookup_contacts_by_address_list(
|
|
||||||
context,
|
context,
|
||||||
&field_from,
|
&field_from,
|
||||||
Origin::IncomingUnknownFrom,
|
Origin::IncomingUnknownFrom,
|
||||||
&mut from_ids,
|
|
||||||
)?;
|
)?;
|
||||||
if from_ids.len() > 1 {
|
if from_ids.len() > 1 {
|
||||||
warn!(
|
warn!(
|
||||||
@@ -137,9 +133,10 @@ pub fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut to_ids = ContactIds::new();
|
||||||
for header_def in &[HeaderDef::To, HeaderDef::Cc] {
|
for header_def in &[HeaderDef::To, HeaderDef::Cc] {
|
||||||
if let Some(field) = mime_parser.get(header_def.clone()) {
|
if let Some(field) = mime_parser.get(header_def.clone()) {
|
||||||
dc_add_or_lookup_contacts_by_address_list(
|
to_ids.extend(&dc_add_or_lookup_contacts_by_address_list(
|
||||||
context,
|
context,
|
||||||
&field,
|
&field,
|
||||||
if !incoming {
|
if !incoming {
|
||||||
@@ -149,8 +146,7 @@ pub fn dc_receive_imf(
|
|||||||
} else {
|
} else {
|
||||||
Origin::IncomingUnknownTo
|
Origin::IncomingUnknownTo
|
||||||
},
|
},
|
||||||
&mut to_ids,
|
)?);
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1516,8 +1512,7 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
addr_list_raw: &str,
|
addr_list_raw: &str,
|
||||||
origin: Origin,
|
origin: Origin,
|
||||||
to_ids: &mut ContactIds,
|
) -> Result<ContactIds> {
|
||||||
) -> Result<()> {
|
|
||||||
let addrs = match mailparse::addrparse(addr_list_raw) {
|
let addrs = match mailparse::addrparse(addr_list_raw) {
|
||||||
Ok(addrs) => addrs,
|
Ok(addrs) => addrs,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -1525,10 +1520,11 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut contact_ids = ContactIds::new();
|
||||||
for addr in addrs.iter() {
|
for addr in addrs.iter() {
|
||||||
match addr {
|
match addr {
|
||||||
mailparse::MailAddr::Single(info) => {
|
mailparse::MailAddr::Single(info) => {
|
||||||
to_ids.insert(add_or_lookup_contact_by_addr(
|
contact_ids.insert(add_or_lookup_contact_by_addr(
|
||||||
context,
|
context,
|
||||||
&info.display_name,
|
&info.display_name,
|
||||||
&info.addr,
|
&info.addr,
|
||||||
@@ -1537,7 +1533,7 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
|||||||
}
|
}
|
||||||
mailparse::MailAddr::Group(infos) => {
|
mailparse::MailAddr::Group(infos) => {
|
||||||
for info in &infos.addrs {
|
for info in &infos.addrs {
|
||||||
to_ids.insert(add_or_lookup_contact_by_addr(
|
contact_ids.insert(add_or_lookup_contact_by_addr(
|
||||||
context,
|
context,
|
||||||
&info.display_name,
|
&info.display_name,
|
||||||
&info.addr,
|
&info.addr,
|
||||||
@@ -1548,7 +1544,7 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(contact_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add contacts to database on receiving messages.
|
/// Add contacts to database on receiving messages.
|
||||||
|
|||||||
Reference in New Issue
Block a user