summaryrefslogtreecommitdiff
path: root/crates/jmap/src/email/ingest.rs
diff options
context:
space:
mode:
authormdecimus <mauro@stalw.art>2024-03-05 10:35:16 +0100
committermdecimus <mauro@stalw.art>2024-03-05 10:35:16 +0100
commit48f255b31f5bafdb0c9056b708646ca81d669929 (patch)
tree04cea010e5b76fd2a943317cfc5e47a62f82e276 /crates/jmap/src/email/ingest.rs
parentff279b3a39c0192ef6d9e728b9b2a852399fc1e4 (diff)
Iterate values rather than sending multiple get requests
Diffstat (limited to 'crates/jmap/src/email/ingest.rs')
-rw-r--r--crates/jmap/src/email/ingest.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/jmap/src/email/ingest.rs b/crates/jmap/src/email/ingest.rs
index 0ce44f33..b5caeea5 100644
--- a/crates/jmap/src/email/ingest.rs
+++ b/crates/jmap/src/email/ingest.rs
@@ -449,14 +449,17 @@ impl JMAP {
})?;
if thread_ids.len() == 1 {
- return Ok(thread_ids.into_iter().next().unwrap());
+ return Ok(thread_ids
+ .into_iter()
+ .next()
+ .map(|(_, thread_id)| thread_id));
}
// Find the most common threadId
let mut thread_counts = VecMap::<u32, u32>::with_capacity(thread_ids.len());
let mut thread_id = u32::MAX;
let mut thread_count = 0;
- for thread_id_ in thread_ids.iter().flatten() {
+ for (_, thread_id_) in thread_ids.iter() {
let tc = thread_counts.get_mut_or_insert(*thread_id_);
*tc += 1;
if *tc > thread_count {
@@ -494,7 +497,11 @@ impl JMAP {
// Move messages to the new threadId
batch.with_collection(Collection::Email);
- for old_thread_id in thread_ids.into_iter().flatten().collect::<AHashSet<_>>() {
+ for old_thread_id in thread_ids
+ .into_iter()
+ .map(|(_, thread_id)| thread_id)
+ .collect::<AHashSet<_>>()
+ {
if thread_id != old_thread_id {
for document_id in self
.store