Skip to content

Commit c486e4f

Browse files
committed
Keep order of contacts in parsed To: and similar headers
1 parent fafd9d1 commit c486e4f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/receive_imf.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,8 @@ async fn add_or_lookup_contacts_by_address_list(
30263026
address_list: &[SingleInfo],
30273027
origin: Origin,
30283028
) -> Result<Vec<ContactId>> {
3029-
let mut contact_ids = HashSet::new();
3029+
let mut contact_ids = Vec::new();
3030+
let mut contact_ids_set = HashSet::new();
30303031
for info in address_list {
30313032
let addr = &info.addr;
30323033
if !may_be_valid_addr(addr) {
@@ -3037,13 +3038,16 @@ async fn add_or_lookup_contacts_by_address_list(
30373038
let (contact_id, _) =
30383039
Contact::add_or_lookup(context, display_name.unwrap_or_default(), &addr, origin)
30393040
.await?;
3040-
contact_ids.insert(contact_id);
3041+
if !contact_ids_set.contains(&contact_id) {
3042+
contact_ids.push(contact_id);
3043+
contact_ids_set.insert(contact_id);
3044+
}
30413045
} else {
30423046
warn!(context, "Contact with address {:?} cannot exist.", addr);
30433047
}
30443048
}
30453049

3046-
Ok(contact_ids.into_iter().collect::<Vec<ContactId>>())
3050+
Ok(contact_ids)
30473051
}
30483052

30493053
#[cfg(test)]

0 commit comments

Comments
 (0)