@@ -32,16 +32,29 @@ use qrinvite::QrInvite;
3232
3333use crate :: token:: Namespace ;
3434
35- fn inviter_progress ( context : & Context , contact_id : ContactId , progress : usize ) {
35+ fn inviter_progress (
36+ context : & Context ,
37+ contact_id : ContactId ,
38+ step : & str ,
39+ progress : usize ,
40+ ) -> Result < ( ) > {
3641 logged_debug_assert ! (
3742 context,
3843 progress <= 1000 ,
3944 "inviter_progress: contact {contact_id}, progress={progress}, but value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success."
4045 ) ;
46+ let chat_type = match step. get ( ..3 ) {
47+ Some ( "vc-" ) => Chattype :: Single ,
48+ Some ( "vg-" ) => Chattype :: Group ,
49+ _ => bail ! ( "Unknown securejoin step {step}" ) ,
50+ } ;
4151 context. emit_event ( EventType :: SecurejoinInviterProgress {
4252 contact_id,
53+ chat_type,
4354 progress,
4455 } ) ;
56+
57+ Ok ( ( ) )
4558}
4659
4760/// Generates a Secure Join QR code.
@@ -346,7 +359,7 @@ pub(crate) async fn handle_securejoin_handshake(
346359 return Ok ( HandshakeMessage :: Ignore ) ;
347360 }
348361
349- inviter_progress ( context, contact_id, 300 ) ;
362+ inviter_progress ( context, contact_id, step , 300 ) ? ;
350363
351364 let from_addr = ContactAddress :: new ( & mime_message. from . addr ) ?;
352365 let autocrypt_fingerprint = mime_message. autocrypt_fingerprint . as_deref ( ) . unwrap_or ( "" ) ;
@@ -442,7 +455,7 @@ pub(crate) async fn handle_securejoin_handshake(
442455 ChatId :: create_for_contact ( context, contact_id) . await ?;
443456 }
444457 context. emit_event ( EventType :: ContactsChanged ( Some ( contact_id) ) ) ;
445- inviter_progress ( context, contact_id, 600 ) ;
458+ inviter_progress ( context, contact_id, step , 600 ) ? ;
446459 if let Some ( group_chat_id) = group_chat_id {
447460 // Join group.
448461 secure_connection_established (
@@ -455,8 +468,8 @@ pub(crate) async fn handle_securejoin_handshake(
455468
456469 chat:: add_contact_to_chat_ex ( context, Nosync , group_chat_id, contact_id, true )
457470 . await ?;
458- inviter_progress ( context, contact_id, 800 ) ;
459- inviter_progress ( context, contact_id, 1000 ) ;
471+ inviter_progress ( context, contact_id, step , 800 ) ? ;
472+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
460473 if step == "vb-request-with-auth" {
461474 // For broadcasts, we don't want to delete the message,
462475 // because the other device should also internally add the member
@@ -480,7 +493,7 @@ pub(crate) async fn handle_securejoin_handshake(
480493 . await
481494 . context ( "failed sending vc-contact-confirm message" ) ?;
482495
483- inviter_progress ( context, contact_id, 1000 ) ;
496+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
484497 Ok ( HandshakeMessage :: Ignore ) // "Done" would delete the message and break multi-device (the key from Autocrypt-header is needed)
485498 }
486499 }
@@ -609,11 +622,11 @@ pub(crate) async fn observe_securejoin_on_other_device(
609622 ChatId :: set_protection_for_contact ( context, contact_id, mime_message. timestamp_sent ) . await ?;
610623
611624 if step == "vg-member-added" {
612- inviter_progress ( context, contact_id, 800 ) ;
625+ inviter_progress ( context, contact_id, step , 800 ) ? ;
613626 }
614627 // TODO superflous vb-member-added (we're early-returning above):
615628 if step == "vg-member-added" || step == "vb-member-added" || step == "vc-contact-confirm" {
616- inviter_progress ( context, contact_id, 1000 ) ;
629+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
617630 }
618631
619632 if step == "vg-request-with-auth" || step == "vc-request-with-auth" {
0 commit comments