listing/conversations: hash addr by addr_spec in from_address_list

While accumulating addresses for the 'From' list for each envelope
entry, hash the addresses by the address spec (i.e. the email address)
instead of the entire address. This prevents duplicates of the same
email address but with different display names.
jmap-eventsource
Manos Pitsidianakis 2020-12-25 05:16:44 +02:00
parent 0034f195e3
commit 2d5f5e767c
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 22 additions and 16 deletions

View File

@ -287,17 +287,20 @@ impl MailListingTrait for ConversationsListing {
} }
from_address_list.clear(); from_address_list.clear();
from_address_set.clear(); from_address_set.clear();
for (_, h) in threads.thread_group_iter(thread) { for envelope in threads
let env_hash = threads.thread_nodes()[&h].message().unwrap(); .thread_group_iter(thread)
.filter_map(|(_, h)| threads.thread_nodes()[&h].message())
let envelope: &EnvelopeRef = &context.accounts[&self.cursor_pos.0] .map(|env_hash| {
.collection context.accounts[&self.cursor_pos.0]
.get_env(env_hash); .collection
.get_env(env_hash)
})
{
for addr in envelope.from().iter() { for addr in envelope.from().iter() {
if from_address_set.contains(addr.raw()) { if from_address_set.contains(addr.address_spec_raw()) {
continue; continue;
} }
from_address_set.insert(addr.raw().to_vec()); from_address_set.insert(addr.address_spec_raw().to_vec());
from_address_list.push(addr.clone()); from_address_list.push(addr.clone());
} }
} }
@ -1045,17 +1048,20 @@ impl ConversationsListing {
let mut from_address_list = Vec::new(); let mut from_address_list = Vec::new();
let mut from_address_set: std::collections::HashSet<Vec<u8>> = let mut from_address_set: std::collections::HashSet<Vec<u8>> =
std::collections::HashSet::new(); std::collections::HashSet::new();
for (_, h) in threads.thread_group_iter(thread_hash) { for envelope in threads
let env_hash = threads.thread_nodes()[&h].message().unwrap(); .thread_group_iter(thread_hash)
.filter_map(|(_, h)| threads.thread_nodes()[&h].message())
let envelope: &EnvelopeRef = &context.accounts[&self.cursor_pos.0] .map(|env_hash| {
.collection context.accounts[&self.cursor_pos.0]
.get_env(env_hash); .collection
.get_env(env_hash)
})
{
for addr in envelope.from().iter() { for addr in envelope.from().iter() {
if from_address_set.contains(addr.raw()) { if from_address_set.contains(addr.address_spec_raw()) {
continue; continue;
} }
from_address_set.insert(addr.raw().to_vec()); from_address_set.insert(addr.address_spec_raw().to_vec());
from_address_list.push(addr.clone()); from_address_list.push(addr.clone());
} }
} }