1
1
//! Internet Message Format reception pipeline.
2
2
3
- use std:: collections:: { HashMap , HashSet } ;
3
+ use std:: collections:: { BTreeMap , HashSet } ;
4
4
use std:: iter;
5
5
use std:: sync:: LazyLock ;
6
6
@@ -28,14 +28,14 @@ use crate::events::EventType;
28
28
use crate :: headerdef:: { HeaderDef , HeaderDefMap } ;
29
29
use crate :: imap:: { GENERATED_PREFIX , markseen_on_imap_table} ;
30
30
use crate :: key:: self_fingerprint_opt;
31
- use crate :: key:: { DcKey , Fingerprint , SignedPublicKey } ;
31
+ use crate :: key:: { DcKey , Fingerprint } ;
32
32
use crate :: log:: LogExt ;
33
33
use crate :: log:: { info, warn} ;
34
34
use crate :: logged_debug_assert;
35
35
use crate :: message:: {
36
36
self , Message , MessageState , MessengerMessage , MsgId , Viewtype , rfc724_mid_exists,
37
37
} ;
38
- use crate :: mimeparser:: { AvatarAction , MimeMessage , SystemMessage , parse_message_ids} ;
38
+ use crate :: mimeparser:: { AvatarAction , GossipedKey , MimeMessage , SystemMessage , parse_message_ids} ;
39
39
use crate :: param:: { Param , Params } ;
40
40
use crate :: peer_channels:: { add_gossip_peer_from_header, insert_topic_stub} ;
41
41
use crate :: reaction:: { Reaction , set_msg_reaction} ;
@@ -743,7 +743,7 @@ pub(crate) async fn receive_imf_inner(
743
743
let verified_encryption = has_verified_encryption ( context, & mime_parser, from_id) . await ?;
744
744
745
745
if verified_encryption == VerifiedEncryption :: Verified {
746
- mark_recipients_as_verified ( context, from_id, & to_ids , & mime_parser) . await ?;
746
+ mark_recipients_as_verified ( context, from_id, & mime_parser) . await ?;
747
747
}
748
748
749
749
let received_msg = if let Some ( received_msg) = received_msg {
@@ -836,7 +836,7 @@ pub(crate) async fn receive_imf_inner(
836
836
context
837
837
. sql
838
838
. transaction ( move |transaction| {
839
- let fingerprint = gossiped_key. dc_fingerprint ( ) . hex ( ) ;
839
+ let fingerprint = gossiped_key. public_key . dc_fingerprint ( ) . hex ( ) ;
840
840
transaction. execute (
841
841
"INSERT INTO gossip_timestamp (chat_id, fingerprint, timestamp)
842
842
VALUES (?, ?, ?)
@@ -2923,7 +2923,7 @@ async fn apply_group_changes(
2923
2923
// highest `add_timestamp` to disambiguate.
2924
2924
// The result of the error is that info message
2925
2925
// may contain display name of the wrong contact.
2926
- let fingerprint = key. dc_fingerprint ( ) . hex ( ) ;
2926
+ let fingerprint = key. public_key . dc_fingerprint ( ) . hex ( ) ;
2927
2927
if let Some ( contact_id) =
2928
2928
lookup_key_contact_by_fingerprint ( context, & fingerprint) . await ?
2929
2929
{
@@ -3662,13 +3662,18 @@ async fn has_verified_encryption(
3662
3662
async fn mark_recipients_as_verified (
3663
3663
context : & Context ,
3664
3664
from_id : ContactId ,
3665
- to_ids : & [ Option < ContactId > ] ,
3666
3665
mimeparser : & MimeMessage ,
3667
3666
) -> Result < ( ) > {
3668
- if mimeparser. get_header ( HeaderDef :: ChatVerified ) . is_none ( ) {
3669
- return Ok ( ( ) ) ;
3670
- }
3671
- for to_id in to_ids. iter ( ) . filter_map ( |& x| x) {
3667
+ for gossiped_key in mimeparser
3668
+ . gossiped_keys
3669
+ . values ( )
3670
+ . filter ( |gossiped_key| gossiped_key. is_verified )
3671
+ {
3672
+ let fingerprint = gossiped_key. public_key . dc_fingerprint ( ) . hex ( ) ;
3673
+ let Some ( to_id) = lookup_key_contact_by_fingerprint ( context, & fingerprint) . await ? else {
3674
+ continue ;
3675
+ } ;
3676
+
3672
3677
if to_id == ContactId :: SELF || to_id == from_id {
3673
3678
continue ;
3674
3679
}
@@ -3760,7 +3765,7 @@ async fn add_or_lookup_contacts_by_address_list(
3760
3765
async fn add_or_lookup_key_contacts (
3761
3766
context : & Context ,
3762
3767
address_list : & [ SingleInfo ] ,
3763
- gossiped_keys : & HashMap < String , SignedPublicKey > ,
3768
+ gossiped_keys : & BTreeMap < String , GossipedKey > ,
3764
3769
fingerprints : & [ Fingerprint ] ,
3765
3770
origin : Origin ,
3766
3771
) -> Result < Vec < Option < ContactId > > > {
@@ -3776,7 +3781,7 @@ async fn add_or_lookup_key_contacts(
3776
3781
// Iterator has not ran out of fingerprints yet.
3777
3782
fp. hex ( )
3778
3783
} else if let Some ( key) = gossiped_keys. get ( addr) {
3779
- key. dc_fingerprint ( ) . hex ( )
3784
+ key. public_key . dc_fingerprint ( ) . hex ( )
3780
3785
} else if context. is_self_addr ( addr) . await ? {
3781
3786
contact_ids. push ( Some ( ContactId :: SELF ) ) ;
3782
3787
continue ;
0 commit comments