@@ -405,8 +405,11 @@ pub(crate) async fn receive_imf_inner(
405
405
received_msg = None ;
406
406
}
407
407
408
- let verified_encryption =
409
- has_verified_encryption ( context, & mime_parser, from_id, & to_ids) . await ?;
408
+ let verified_encryption = has_verified_encryption ( & mime_parser, from_id) ?;
409
+
410
+ if verified_encryption == VerifiedEncryption :: Verified {
411
+ mark_recipients_as_verified ( context, from_id, & to_ids, & mime_parser) . await ?;
412
+ }
410
413
411
414
if verified_encryption == VerifiedEncryption :: Verified
412
415
&& mime_parser. get_header ( HeaderDef :: ChatVerified ) . is_some ( )
@@ -3059,23 +3062,12 @@ async fn update_verified_keys(
3059
3062
/// Checks whether the message is allowed to appear in a protected chat.
3060
3063
///
3061
3064
/// This means that it is encrypted and signed with a verified key.
3062
- ///
3063
- /// Also propagates gossiped keys to verified if needed.
3064
- async fn has_verified_encryption (
3065
- context : & Context ,
3065
+ fn has_verified_encryption (
3066
3066
mimeparser : & MimeMessage ,
3067
3067
from_id : ContactId ,
3068
- to_ids : & [ ContactId ] ,
3069
3068
) -> Result < VerifiedEncryption > {
3070
3069
use VerifiedEncryption :: * ;
3071
3070
3072
- // We do not need to check if we are verified with ourself.
3073
- let to_ids = to_ids
3074
- . iter ( )
3075
- . copied ( )
3076
- . filter ( |id| * id != ContactId :: SELF )
3077
- . collect :: < Vec < ContactId > > ( ) ;
3078
-
3079
3071
if !mimeparser. was_encrypted ( ) {
3080
3072
return Ok ( NotVerified ( "This message is not encrypted" . to_string ( ) ) ) ;
3081
3073
} ;
@@ -3104,21 +3096,24 @@ async fn has_verified_encryption(
3104
3096
}
3105
3097
}
3106
3098
3107
- mark_recipients_as_verified ( context, from_id, to_ids, mimeparser) . await ?;
3108
3099
Ok ( Verified )
3109
3100
}
3110
3101
3111
3102
async fn mark_recipients_as_verified (
3112
3103
context : & Context ,
3113
3104
from_id : ContactId ,
3114
- to_ids : Vec < ContactId > ,
3105
+ to_ids : & [ ContactId ] ,
3115
3106
mimeparser : & MimeMessage ,
3116
3107
) -> Result < ( ) > {
3117
3108
if mimeparser. get_header ( HeaderDef :: ChatVerified ) . is_none ( ) {
3118
3109
return Ok ( ( ) ) ;
3119
3110
}
3120
3111
let contact = Contact :: get_by_id ( context, from_id) . await ?;
3121
- for id in to_ids {
3112
+ for & id in to_ids {
3113
+ if id == ContactId :: SELF {
3114
+ continue ;
3115
+ }
3116
+
3122
3117
let Some ( ( to_addr, is_verified) ) = context
3123
3118
. sql
3124
3119
. query_row_optional (
0 commit comments