Skip to content

Commit ab4cb01

Browse files
committed
fix: do not try to lookup key-contacts for unencrypted 1:1 messages
1 parent 661a886 commit ab4cb01

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/receive_imf.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,31 @@ async fn get_to_and_past_contact_ids(
394394
// This is an encrypted 1:1 chat.
395395
to_ids = pgp_to_ids
396396
} else if let Some(chat_id) = chat_id {
397-
to_ids = lookup_key_contacts_by_address_list(
398-
context,
399-
&mime_parser.recipients,
400-
to_member_fingerprints,
401-
Some(chat_id),
402-
)
403-
.await?;
397+
to_ids = match mime_parser.was_encrypted() {
398+
true => {
399+
lookup_key_contacts_by_address_list(
400+
context,
401+
&mime_parser.recipients,
402+
to_member_fingerprints,
403+
Some(chat_id),
404+
)
405+
.await?
406+
}
407+
false => {
408+
add_or_lookup_contacts_by_address_list(
409+
context,
410+
&mime_parser.recipients,
411+
if !mime_parser.incoming {
412+
Origin::OutgoingTo
413+
} else if incoming_origin.is_known() {
414+
Origin::IncomingTo
415+
} else {
416+
Origin::IncomingUnknownTo
417+
},
418+
)
419+
.await?
420+
}
421+
}
404422
} else {
405423
let ids = match mime_parser.was_encrypted() {
406424
true => {

0 commit comments

Comments
 (0)