@@ -8,7 +8,6 @@ use crate::chat::{self, ChatId};
8
8
use crate :: config:: Config ;
9
9
use crate :: contact:: ContactId ;
10
10
use crate :: context:: Context ;
11
- use crate :: imex:: maybe_add_bcc_self_device_msg;
12
11
use crate :: imex:: set_self_key;
13
12
use crate :: key:: { load_self_secret_key, DcKey } ;
14
13
use crate :: message:: { Message , MsgId , Viewtype } ;
@@ -48,11 +47,10 @@ pub async fn initiate_key_transfer(context: &Context) -> Result<String> {
48
47
msg. param . set_int ( Param :: SkipAutocrypt , 1 ) ;
49
48
50
49
chat:: send_msg ( context, chat_id, & mut msg) . await ?;
51
- // no maybe_add_bcc_self_device_msg() here.
52
- // the ui shows the dialog with the setup code on this device,
53
- // it would be too much noise to have two things popping up at the same time.
54
- // maybe_add_bcc_self_device_msg() is called on the other device
55
- // once the transfer is completed.
50
+
51
+ // Enable BCC-self, because transferring a key
52
+ // means we have a multi-device setup.
53
+ context. set_config_bool ( Config :: BccSelf , true ) . await ?;
56
54
Ok ( setup_code)
57
55
}
58
56
@@ -78,7 +76,7 @@ pub async fn continue_key_transfer(
78
76
let sc = normalize_setup_code ( setup_code) ;
79
77
let armored_key = decrypt_setup_file ( & sc, file) . await ?;
80
78
set_self_key ( context, & armored_key, true ) . await ?;
81
- maybe_add_bcc_self_device_msg ( context) . await ?;
79
+ context. set_config_bool ( Config :: BccSelf , true ) . await ?;
82
80
83
81
Ok ( ( ) )
84
82
} else {
@@ -301,8 +299,12 @@ mod tests {
301
299
async fn test_key_transfer ( ) -> Result < ( ) > {
302
300
let alice = TestContext :: new_alice ( ) . await ;
303
301
302
+ alice. set_config ( Config :: BccSelf , Some ( "0" ) ) . await ?;
304
303
let setup_code = initiate_key_transfer ( & alice) . await ?;
305
304
305
+ // Test that sending Autocrypt Setup Message enables `bcc_self`.
306
+ assert_eq ! ( alice. get_config_bool( Config :: BccSelf ) . await ?, true ) ;
307
+
306
308
// Get Autocrypt Setup Message.
307
309
let sent = alice. pop_sent_msg ( ) . await ;
308
310
@@ -322,12 +324,14 @@ mod tests {
322
324
assert_ne ! ( alice. get_last_msg( ) . await . get_text( ) , "Test" ) ;
323
325
324
326
// Transfer the key.
327
+ alice2. set_config ( Config :: BccSelf , Some ( "0" ) ) . await ?;
325
328
continue_key_transfer ( & alice2, msg. id , & setup_code) . await ?;
329
+ assert_eq ! ( alice2. get_config_bool( Config :: BccSelf ) . await ?, true ) ;
326
330
327
331
// Alice sends a message to self from the new device.
328
332
let sent = alice2. send_text ( msg. chat_id , "Test" ) . await ;
329
- alice. recv_msg ( & sent) . await ;
330
- assert_eq ! ( alice . get_last_msg ( ) . await . get_text( ) , "Test" ) ;
333
+ let rcvd_msg = alice. recv_msg ( & sent) . await ;
334
+ assert_eq ! ( rcvd_msg . get_text( ) , "Test" ) ;
331
335
332
336
Ok ( ( ) )
333
337
}
0 commit comments