@@ -32,16 +32,30 @@ use qrinvite::QrInvite;
32
32
33
33
use crate :: token:: Namespace ;
34
34
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 < ( ) > {
36
41
logged_debug_assert ! (
37
42
context,
38
43
progress <= 1000 ,
39
44
"inviter_progress: contact {contact_id}, progress={progress}, but value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success."
40
45
) ;
46
+ let chat_type = match step. get ( ..3 ) {
47
+ Some ( "vc-" ) => Chattype :: Single ,
48
+ Some ( "vg-" ) => Chattype :: Group ,
49
+ Some ( "vb-" ) => Chattype :: OutBroadcast ,
50
+ _ => bail ! ( "Unknown securejoin step {step}" ) ,
51
+ } ;
41
52
context. emit_event ( EventType :: SecurejoinInviterProgress {
42
53
contact_id,
54
+ chat_type,
43
55
progress,
44
56
} ) ;
57
+
58
+ Ok ( ( ) )
45
59
}
46
60
47
61
/// Generates a Secure Join QR code.
@@ -346,7 +360,7 @@ pub(crate) async fn handle_securejoin_handshake(
346
360
return Ok ( HandshakeMessage :: Ignore ) ;
347
361
}
348
362
349
- inviter_progress ( context, contact_id, 300 ) ;
363
+ inviter_progress ( context, contact_id, step , 300 ) ? ;
350
364
351
365
let from_addr = ContactAddress :: new ( & mime_message. from . addr ) ?;
352
366
let autocrypt_fingerprint = mime_message. autocrypt_fingerprint . as_deref ( ) . unwrap_or ( "" ) ;
@@ -442,7 +456,7 @@ pub(crate) async fn handle_securejoin_handshake(
442
456
ChatId :: create_for_contact ( context, contact_id) . await ?;
443
457
}
444
458
context. emit_event ( EventType :: ContactsChanged ( Some ( contact_id) ) ) ;
445
- inviter_progress ( context, contact_id, 600 ) ;
459
+ inviter_progress ( context, contact_id, step , 600 ) ? ;
446
460
if let Some ( group_chat_id) = group_chat_id {
447
461
// Join group.
448
462
secure_connection_established (
@@ -455,8 +469,8 @@ pub(crate) async fn handle_securejoin_handshake(
455
469
456
470
chat:: add_contact_to_chat_ex ( context, Nosync , group_chat_id, contact_id, true )
457
471
. await ?;
458
- inviter_progress ( context, contact_id, 800 ) ;
459
- inviter_progress ( context, contact_id, 1000 ) ;
472
+ inviter_progress ( context, contact_id, step , 800 ) ? ;
473
+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
460
474
if step == "vb-request-with-auth" {
461
475
// For broadcasts, we don't want to delete the message,
462
476
// because the other device should also internally add the member
@@ -480,7 +494,7 @@ pub(crate) async fn handle_securejoin_handshake(
480
494
. await
481
495
. context ( "failed sending vc-contact-confirm message" ) ?;
482
496
483
- inviter_progress ( context, contact_id, 1000 ) ;
497
+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
484
498
Ok ( HandshakeMessage :: Ignore ) // "Done" would delete the message and break multi-device (the key from Autocrypt-header is needed)
485
499
}
486
500
}
@@ -609,11 +623,11 @@ pub(crate) async fn observe_securejoin_on_other_device(
609
623
ChatId :: set_protection_for_contact ( context, contact_id, mime_message. timestamp_sent ) . await ?;
610
624
611
625
if step == "vg-member-added" {
612
- inviter_progress ( context, contact_id, 800 ) ;
626
+ inviter_progress ( context, contact_id, step , 800 ) ? ;
613
627
}
614
628
// TODO superflous vb-member-added (we're early-returning above):
615
629
if step == "vg-member-added" || step == "vb-member-added" || step == "vc-contact-confirm" {
616
- inviter_progress ( context, contact_id, 1000 ) ;
630
+ inviter_progress ( context, contact_id, step , 1000 ) ? ;
617
631
}
618
632
619
633
if step == "vg-request-with-auth" || step == "vc-request-with-auth" {
0 commit comments