@@ -161,7 +161,7 @@ impl MimeFactory {
161
161
pub async fn from_msg ( context : & Context , msg : Message ) -> Result < MimeFactory > {
162
162
let now = time ( ) ;
163
163
let chat = Chat :: load_from_db ( context, msg. chat_id ) . await ?;
164
- let attach_profile_data = Self :: should_attach_profile_data ( & msg) ;
164
+ let attach_profile_data = Self :: should_attach_profile_data ( context , & msg) . await ? ;
165
165
let undisclosed_recipients = chat. typ == Chattype :: Broadcast ;
166
166
167
167
let from_addr = context. get_primary_self_addr ( ) . await ?;
@@ -312,7 +312,7 @@ impl MimeFactory {
312
312
. unwrap_or_default ( ) ,
313
313
false => "" . to_string ( ) ,
314
314
} ;
315
- let attach_selfavatar = Self :: should_attach_selfavatar ( context, & msg) . await ;
315
+ let attach_selfavatar = Self :: should_attach_selfavatar ( context, & msg) . await ? ;
316
316
317
317
debug_assert ! (
318
318
member_timestamps. is_empty( )
@@ -434,8 +434,14 @@ impl MimeFactory {
434
434
}
435
435
}
436
436
437
- fn should_attach_profile_data ( msg : & Message ) -> bool {
438
- msg. param . get_cmd ( ) != SystemMessage :: SecurejoinMessage || {
437
+ async fn should_attach_profile_data ( context : & Context , msg : & Message ) -> Result < bool > {
438
+ if msg. param . get_cmd ( ) == SystemMessage :: MemberRemovedFromGroup
439
+ && msg. param . get ( Param :: Arg )
440
+ == context. get_config ( Config :: ConfiguredAddr ) . await ?. as_deref ( )
441
+ {
442
+ return Ok ( false ) ;
443
+ }
444
+ Ok ( msg. param . get_cmd ( ) != SystemMessage :: SecurejoinMessage || {
439
445
let step = msg. param . get ( Param :: Arg ) . unwrap_or_default ( ) ;
440
446
// Don't attach profile data at the earlier SecureJoin steps:
441
447
// - The corresponding messages, i.e. "v{c,g}-request" and "v{c,g}-auth-required" are
@@ -446,11 +452,11 @@ impl MimeFactory {
446
452
|| step == "vc-request-with-auth"
447
453
|| step == "vg-member-added"
448
454
|| step == "vc-contact-confirm"
449
- }
455
+ } )
450
456
}
451
457
452
- async fn should_attach_selfavatar ( context : & Context , msg : & Message ) -> bool {
453
- Self :: should_attach_profile_data ( msg)
458
+ async fn should_attach_selfavatar ( context : & Context , msg : & Message ) -> Result < bool > {
459
+ Ok ( Self :: should_attach_profile_data ( context , msg) . await ?
454
460
&& match chat:: shall_attach_selfavatar ( context, msg. chat_id ) . await {
455
461
Ok ( should) => should,
456
462
Err ( err) => {
@@ -460,7 +466,7 @@ impl MimeFactory {
460
466
) ;
461
467
false
462
468
}
463
- }
469
+ } )
464
470
}
465
471
466
472
fn grpimage ( & self ) -> Option < String > {
@@ -521,7 +527,7 @@ impl MimeFactory {
521
527
return Ok ( format ! ( "Re: {}" , remove_subject_prefix( last_subject) ) ) ;
522
528
}
523
529
524
- let self_name = match Self :: should_attach_profile_data ( msg) {
530
+ let self_name = match Self :: should_attach_profile_data ( context , msg) . await ? {
525
531
true => context. get_config ( Config :: Displayname ) . await ?,
526
532
false => None ,
527
533
} ;
0 commit comments