@@ -249,8 +249,6 @@ fn starts_with_ignore_case(string: &str, pattern: &str) -> bool {
249
249
/// The function should be called after a QR code is scanned.
250
250
/// The function takes the raw text scanned and checks what can be done with it.
251
251
pub async fn check_qr ( context : & Context , qr : & str ) -> Result < Qr > {
252
- info ! ( context, "Scanned QR code: {}" , qr) ;
253
-
254
252
let qrcode = if starts_with_ignore_case ( qr, OPENPGP4FPR_SCHEME ) {
255
253
decode_openpgp ( context, qr)
256
254
. await
@@ -474,8 +472,7 @@ fn decode_account(qr: &str) -> Result<Qr> {
474
472
let payload = qr
475
473
. get ( DCACCOUNT_SCHEME . len ( ) ..)
476
474
. context ( "invalid DCACCOUNT payload" ) ?;
477
- let url =
478
- url:: Url :: parse ( payload) . with_context ( || format ! ( "Invalid account URL: {payload:?}" ) ) ?;
475
+ let url = url:: Url :: parse ( payload) . context ( "Invalid account URL" ) ?;
479
476
if url. scheme ( ) == "http" || url. scheme ( ) == "https" {
480
477
Ok ( Qr :: Account {
481
478
domain : url
@@ -484,7 +481,7 @@ fn decode_account(qr: &str) -> Result<Qr> {
484
481
. to_string ( ) ,
485
482
} )
486
483
} else {
487
- bail ! ( "Bad scheme for account URL: {:?}." , payload ) ;
484
+ bail ! ( "Bad scheme for account URL: {:?}." , url . scheme ( ) ) ;
488
485
}
489
486
}
490
487
@@ -495,8 +492,7 @@ fn decode_webrtc_instance(_context: &Context, qr: &str) -> Result<Qr> {
495
492
. context ( "invalid DCWEBRTC payload" ) ?;
496
493
497
494
let ( _type, url) = Message :: parse_webrtc_instance ( payload) ;
498
- let url =
499
- url:: Url :: parse ( & url) . with_context ( || format ! ( "Invalid WebRTC instance: {payload:?}" ) ) ?;
495
+ let url = url:: Url :: parse ( & url) . context ( "Invalid WebRTC instance" ) ?;
500
496
501
497
if url. scheme ( ) == "http" || url. scheme ( ) == "https" {
502
498
Ok ( Qr :: WebrtcInstance {
@@ -507,7 +503,7 @@ fn decode_webrtc_instance(_context: &Context, qr: &str) -> Result<Qr> {
507
503
instance_pattern : payload. to_string ( ) ,
508
504
} )
509
505
} else {
510
- bail ! ( "Bad URL scheme for WebRTC instance: {:?}" , payload ) ;
506
+ bail ! ( "Bad URL scheme for WebRTC instance: {:?}" , url . scheme ( ) ) ;
511
507
}
512
508
}
513
509
@@ -549,16 +545,15 @@ async fn set_account_from_qr(context: &Context, qr: &str) -> Result<()> {
549
545
. send ( )
550
546
. await ?;
551
547
let response_status = response. status ( ) ;
552
- let response_text = response. text ( ) . await . with_context ( || {
553
- format ! ( "Cannot create account, request to {url_str:?} failed: empty response" )
554
- } ) ?;
548
+ let response_text = response
549
+ . text ( )
550
+ . await
551
+ . context ( "Cannot create account, request failed: empty response" ) ?;
555
552
556
553
if response_status. is_success ( ) {
557
554
let CreateAccountSuccessResponse { password, email } = serde_json:: from_str ( & response_text)
558
555
. with_context ( || {
559
- format ! (
560
- "Cannot create account, response from {url_str:?} is malformed:\n {response_text:?}"
561
- )
556
+ format ! ( "Cannot create account, response is malformed:\n {response_text:?}" )
562
557
} ) ?;
563
558
context
564
559
. set_config_internal ( Config :: Addr , Some ( & email) )
@@ -653,7 +648,7 @@ pub async fn set_config_from_qr(context: &Context, qr: &str) -> Result<()> {
653
648
Qr :: Login { address, options } => {
654
649
configure_from_login_qr ( context, & address, options) . await ?
655
650
}
656
- _ => bail ! ( "qr code {:?} does not contain config" , qr ) ,
651
+ _ => bail ! ( "QR code does not contain config" ) ,
657
652
}
658
653
659
654
Ok ( ( ) )
0 commit comments