@@ -353,18 +353,38 @@ pub(crate) async fn receive_imf_inner(
353
353
} ,
354
354
)
355
355
. await ?;
356
- let past_ids = add_or_lookup_contacts_by_address_list (
357
- context,
358
- & mime_parser. past_members ,
359
- if !mime_parser. incoming {
360
- Origin :: OutgoingTo
361
- } else if incoming_origin. is_known ( ) {
362
- Origin :: IncomingTo
356
+
357
+ let chat_id: Option < ChatId > = if let Some ( grpid) = mime_parser. get_chat_group_id ( ) {
358
+ if let Some ( ( chat_id, _protected, _blocked) ) =
359
+ chat:: get_chat_id_by_grpid ( context, & grpid) . await ?
360
+ {
361
+ Some ( chat_id)
363
362
} else {
364
- Origin :: IncomingUnknownTo
365
- } ,
366
- )
367
- . await ?;
363
+ None
364
+ }
365
+ } else {
366
+ None
367
+ } ;
368
+
369
+ let past_ids: Vec < Option < ContactId > > = if let Some ( chat_id) = chat_id {
370
+ lookup_pgp_contacts_by_address_list ( context, & mime_parser. past_members , chat_id) . await ?
371
+ } else {
372
+ add_or_lookup_contacts_by_address_list (
373
+ context,
374
+ & mime_parser. past_members ,
375
+ if !mime_parser. incoming {
376
+ Origin :: OutgoingTo
377
+ } else if incoming_origin. is_known ( ) {
378
+ Origin :: IncomingTo
379
+ } else {
380
+ Origin :: IncomingUnknownTo
381
+ } ,
382
+ )
383
+ . await ?
384
+ . into_iter ( )
385
+ . map ( |contact_id| Some ( contact_id) )
386
+ . collect ( )
387
+ } ;
368
388
369
389
update_verified_keys ( context, & mut mime_parser, from_id) . await ?;
370
390
@@ -716,7 +736,7 @@ async fn add_parts(
716
736
mime_parser : & mut MimeMessage ,
717
737
imf_raw : & [ u8 ] ,
718
738
to_ids : & [ ContactId ] ,
719
- past_ids : & [ ContactId ] ,
739
+ past_ids : & [ Option < ContactId > ] ,
720
740
rfc724_mid : & str ,
721
741
from_id : ContactId ,
722
742
seen : bool ,
@@ -2136,7 +2156,7 @@ async fn create_group(
2136
2156
create_blocked : Blocked ,
2137
2157
from_id : ContactId ,
2138
2158
to_ids : & [ ContactId ] ,
2139
- past_ids : & [ ContactId ] ,
2159
+ past_ids : & [ Option < ContactId > ] ,
2140
2160
verified_encryption : & VerifiedEncryption ,
2141
2161
grpid : & str ,
2142
2162
) -> Result < Option < ( ChatId , Blocked ) > > {
@@ -2271,7 +2291,7 @@ async fn update_chats_contacts_timestamps(
2271
2291
chat_id : ChatId ,
2272
2292
ignored_id : Option < ContactId > ,
2273
2293
to_ids : & [ ContactId ] ,
2274
- past_ids : & [ ContactId ] ,
2294
+ past_ids : & [ Option < ContactId > ] ,
2275
2295
chat_group_member_timestamps : & [ i64 ] ,
2276
2296
) -> Result < bool > {
2277
2297
let expected_timestamps_count = to_ids. len ( ) + past_ids. len ( ) ;
@@ -2364,7 +2384,7 @@ async fn apply_group_changes(
2364
2384
chat_id : ChatId ,
2365
2385
from_id : ContactId ,
2366
2386
to_ids : & [ ContactId ] ,
2367
- past_ids : & [ ContactId ] ,
2387
+ past_ids : & [ Option < ContactId > ] ,
2368
2388
verified_encryption : & VerifiedEncryption ,
2369
2389
) -> Result < GroupChangesInfo > {
2370
2390
if chat_id. is_special ( ) {
@@ -3287,18 +3307,21 @@ async fn lookup_pgp_contacts_by_address_list(
3287
3307
for info in address_list {
3288
3308
let addr = & info. addr ;
3289
3309
3290
- let contact_id = context. sql . query_row_optional (
3291
- "SELECT id FROM contacts
3310
+ let contact_id = context
3311
+ . sql
3312
+ . query_row_optional (
3313
+ "SELECT id FROM contacts
3292
3314
WHERE contacts.addr=?
3293
3315
AND EXISTS (SELECT 1 FROM chats_contacts
3294
3316
WHERE contact_id=contacts.id
3295
3317
AND chat_id=?)" ,
3296
- ( addr, chat_id) ,
3297
- |row| {
3298
- let contact_id: ContactId = row. get ( 0 ) ?;
3299
- Ok ( contact_id)
3300
- } ,
3301
- ) . await ?;
3318
+ ( addr, chat_id) ,
3319
+ |row| {
3320
+ let contact_id: ContactId = row. get ( 0 ) ?;
3321
+ Ok ( contact_id)
3322
+ } ,
3323
+ )
3324
+ . await ?;
3302
3325
contact_ids. push ( contact_id) ;
3303
3326
}
3304
3327
debug_assert_eq ! ( address_list. len( ) , contact_ids. len( ) ) ;
0 commit comments