Skip to content

Commit 918277f

Browse files
committed
clippy
1 parent a04f7b3 commit 918277f

File tree

7 files changed

+51
-58
lines changed

7 files changed

+51
-58
lines changed

src/chat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4894,7 +4894,7 @@ async fn set_contacts_by_fingerprints(
48944894
for (fingerprint, addr) in fingerprint_addrs {
48954895
let contact_addr = ContactAddress::new(addr)?;
48964896
let contact =
4897-
Contact::add_or_lookup_ex(context, "", &contact_addr, &fingerprint, Origin::Hidden)
4897+
Contact::add_or_lookup_ex(context, "", &contact_addr, fingerprint, Origin::Hidden)
48984898
.await?
48994899
.0;
49004900
contacts.insert(contact);

src/chat/chat_tests.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -2654,17 +2654,17 @@ async fn test_chat_get_encryption_info() -> Result<()> {
26542654

26552655
add_contact_to_chat(alice, chat_id, contact_bob).await?;
26562656
assert_eq!(
2657-
chat_id.get_encryption_info(&alice).await?,
2657+
chat_id.get_encryption_info(alice).await?,
26582658
"End-to-end encryption available\n\
26592659
\n\
26602660
26612661
CCCB 5AA9 F6E1 141C 9431\n\
26622662
65F1 DB18 B18C BCF7 0487"
26632663
);
26642664

2665-
add_contact_to_chat(&alice, chat_id, contact_fiona).await?;
2665+
add_contact_to_chat(alice, chat_id, contact_fiona).await?;
26662666
assert_eq!(
2667-
chat_id.get_encryption_info(&alice).await?,
2667+
chat_id.get_encryption_info(alice).await?,
26682668
"End-to-end encryption available\n\
26692669
\n\
26702670
@@ -2678,7 +2678,7 @@ async fn test_chat_get_encryption_info() -> Result<()> {
26782678

26792679
let email_chat = alice.create_email_chat(bob).await;
26802680
assert_eq!(
2681-
email_chat.id.get_encryption_info(&alice).await?,
2681+
email_chat.id.get_encryption_info(alice).await?,
26822682
"No encryption"
26832683
);
26842684

@@ -2892,29 +2892,29 @@ async fn test_sync_blocked() -> Result<()> {
28922892
let sent_msg = bob.send_text(ba_chat.id, "hi").await;
28932893
let a0b_chat_id = alice0.recv_msg(&sent_msg).await.chat_id;
28942894
alice1.recv_msg(&sent_msg).await;
2895-
let a0b_contact_id = alice0.add_or_lookup_contact_id(&bob).await;
2895+
let a0b_contact_id = alice0.add_or_lookup_contact_id(bob).await;
28962896

2897-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Request);
2897+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Request);
28982898
a0b_chat_id.accept(alice0).await?;
28992899
sync(alice0, alice1).await;
2900-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Not);
2900+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Not);
29012901
a0b_chat_id.block(alice0).await?;
29022902
sync(alice0, alice1).await;
2903-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Yes);
2903+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Yes);
29042904
a0b_chat_id.unblock(alice0).await?;
29052905
sync(alice0, alice1).await;
2906-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Not);
2906+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Not);
29072907

29082908
// Unblocking a 1:1 chat doesn't unblock the contact currently.
29092909
Contact::unblock(alice0, a0b_contact_id).await?;
29102910

2911-
assert!(!alice1.add_or_lookup_contact(&bob).await.is_blocked());
2911+
assert!(!alice1.add_or_lookup_contact(bob).await.is_blocked());
29122912
Contact::block(alice0, a0b_contact_id).await?;
29132913
sync(alice0, alice1).await;
2914-
assert!(alice1.add_or_lookup_contact(&bob).await.is_blocked());
2914+
assert!(alice1.add_or_lookup_contact(bob).await.is_blocked());
29152915
Contact::unblock(alice0, a0b_contact_id).await?;
29162916
sync(alice0, alice1).await;
2917-
assert!(!alice1.add_or_lookup_contact(&bob).await.is_blocked());
2917+
assert!(!alice1.add_or_lookup_contact(bob).await.is_blocked());
29182918

29192919
// Test accepting and blocking groups. This way we test:
29202920
// - Group chats synchronisation.
@@ -3221,7 +3221,7 @@ async fn test_sync_broadcast() -> Result<()> {
32213221
a.set_config_bool(Config::SyncMsgs, true).await?;
32223222
}
32233223
let bob = &tcm.bob().await;
3224-
let a0b_contact_id = alice0.add_or_lookup_contact(&bob).await.id;
3224+
let a0b_contact_id = alice0.add_or_lookup_contact(bob).await.id;
32253225

32263226
let a0_broadcast_id = create_broadcast_list(alice0).await?;
32273227
sync(alice0, alice1).await;
@@ -3248,7 +3248,7 @@ async fn test_sync_broadcast() -> Result<()> {
32483248
);
32493249
let sent_msg = alice1.send_text(a1_broadcast_id, "hi").await;
32503250
let msg = bob.recv_msg(&sent_msg).await;
3251-
let chat = Chat::load_from_db(&bob, msg.chat_id).await?;
3251+
let chat = Chat::load_from_db(bob, msg.chat_id).await?;
32523252
assert_eq!(chat.get_type(), Chattype::Mailinglist);
32533253
let msg = alice0.recv_msg(&sent_msg).await;
32543254
assert_eq!(msg.chat_id, a0_broadcast_id);

src/contact/contact_tests.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -733,20 +733,20 @@ async fn test_contact_get_encrinfo() -> Result<()> {
733733
let bob = &tcm.bob().await;
734734

735735
// Return error for special IDs
736-
let encrinfo = Contact::get_encrinfo(&alice, ContactId::SELF).await;
736+
let encrinfo = Contact::get_encrinfo(alice, ContactId::SELF).await;
737737
assert!(encrinfo.is_err());
738-
let encrinfo = Contact::get_encrinfo(&alice, ContactId::DEVICE).await;
738+
let encrinfo = Contact::get_encrinfo(alice, ContactId::DEVICE).await;
739739
assert!(encrinfo.is_err());
740740

741741
let email_contact_bob_id = alice.add_or_lookup_email_contact_id(bob).await;
742-
let encrinfo = Contact::get_encrinfo(&alice, email_contact_bob_id).await?;
742+
let encrinfo = Contact::get_encrinfo(alice, email_contact_bob_id).await?;
743743
assert_eq!(encrinfo, "No encryption");
744744

745-
let contact = Contact::get_by_id(&alice, email_contact_bob_id).await?;
746-
assert!(!contact.e2ee_avail(&alice).await?);
745+
let contact = Contact::get_by_id(alice, email_contact_bob_id).await?;
746+
assert!(!contact.e2ee_avail(alice).await?);
747747

748748
let contact_bob_id = alice.add_or_lookup_contact_id(bob).await;
749-
let encrinfo = Contact::get_encrinfo(&alice, contact_bob_id).await?;
749+
let encrinfo = Contact::get_encrinfo(alice, contact_bob_id).await?;
750750
assert_eq!(
751751
encrinfo,
752752
"End-to-end encryption available.
@@ -760,8 +760,8 @@ [email protected] ([email protected]):
760760
CCCB 5AA9 F6E1 141C 9431
761761
65F1 DB18 B18C BCF7 0487"
762762
);
763-
let contact = Contact::get_by_id(&alice, contact_bob_id).await?;
764-
assert!(contact.e2ee_avail(&alice).await?);
763+
let contact = Contact::get_by_id(alice, contact_bob_id).await?;
764+
assert!(contact.e2ee_avail(alice).await?);
765765
Ok(())
766766
}
767767

@@ -786,7 +786,7 @@ async fn test_synchronize_status() -> Result<()> {
786786
let chat = alice1.create_email_chat(bob).await;
787787

788788
// Alice sends a message to Bob from the first device.
789-
send_text_msg(&alice1, chat.id, "Hello".to_string()).await?;
789+
send_text_msg(alice1, chat.id, "Hello".to_string()).await?;
790790
let sent_msg = alice1.pop_sent_msg().await;
791791

792792
// Message is not encrypted.
@@ -804,7 +804,7 @@ async fn test_synchronize_status() -> Result<()> {
804804

805805
// Alice sends encrypted message.
806806
let chat = alice1.create_chat(bob).await;
807-
send_text_msg(&alice1, chat.id, "Hello".to_string()).await?;
807+
send_text_msg(alice1, chat.id, "Hello".to_string()).await?;
808808
let sent_msg = alice1.pop_sent_msg().await;
809809

810810
// Second message is encrypted.
@@ -850,7 +850,7 @@ async fn test_selfavatar_changed_event() -> Result<()> {
850850

851851
// Alice sends a message.
852852
let alice1_chat_id = alice1.create_chat(bob).await.id;
853-
send_text_msg(&alice1, alice1_chat_id, "Hello".to_string()).await?;
853+
send_text_msg(alice1, alice1_chat_id, "Hello".to_string()).await?;
854854
let sent_msg = alice1.pop_sent_msg().await;
855855

856856
// The message is encrypted.

src/imex/key_transfer.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,14 @@ mod tests {
313313
alice2.recv_msg(&sent).await;
314314
let msg = alice2.get_last_msg().await;
315315
assert!(msg.is_setupmessage());
316-
assert_eq!(
317-
crate::key::load_self_secret_keyring(&alice2).await?.len(),
318-
0
319-
);
316+
assert_eq!(crate::key::load_self_secret_keyring(alice2).await?.len(), 0);
320317

321318
// Transfer the key.
322319
tcm.section("Alice imports a key from Autocrypt Setup Message");
323320
alice2.set_config(Config::BccSelf, Some("0")).await?;
324-
continue_key_transfer(&alice2, msg.id, &setup_code).await?;
321+
continue_key_transfer(alice2, msg.id, &setup_code).await?;
325322
assert_eq!(alice2.get_config_bool(Config::BccSelf).await?, true);
326-
assert_eq!(
327-
crate::key::load_self_secret_keyring(&alice2).await?.len(),
328-
1
329-
);
323+
assert_eq!(crate::key::load_self_secret_keyring(alice2).await?.len(), 1);
330324

331325
// Alice sends a message to self from the new device.
332326
let sent = alice2.send_text(msg.chat_id, "Test").await;

src/receive_imf.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub(crate) async fn receive_imf_inner(
324324

325325
let chat_id = if let Some(grpid) = mime_parser.get_chat_group_id() {
326326
if let Some((chat_id, _protected, _blocked)) =
327-
chat::get_chat_id_by_grpid(context, &grpid).await?
327+
chat::get_chat_id_by_grpid(context, grpid).await?
328328
{
329329
Some(chat_id)
330330
} else {
@@ -376,7 +376,7 @@ pub(crate) async fn receive_imf_inner(
376376
past_ids = lookup_pgp_contacts_by_address_list(
377377
context,
378378
&mime_parser.past_members,
379-
&past_member_fingerprints,
379+
past_member_fingerprints,
380380
chat_id,
381381
)
382382
.await?;
@@ -385,15 +385,15 @@ pub(crate) async fn receive_imf_inner(
385385
context,
386386
&mime_parser.past_members,
387387
&mime_parser.gossiped_keys,
388-
&past_member_fingerprints,
388+
past_member_fingerprints,
389389
Origin::Hidden,
390390
)
391391
.await?;
392392
}
393393
} else {
394394
if pgp_to_ids.len() == 1
395395
&& pgp_to_ids
396-
.get(0)
396+
.first()
397397
.is_some_and(|contact_id| contact_id.is_some())
398398
{
399399
// There is a single recipient and we have
@@ -425,18 +425,17 @@ pub(crate) async fn receive_imf_inner(
425425

426426
let received_msg;
427427
if mime_parser.get_header(HeaderDef::SecureJoin).is_some() {
428-
let res;
429-
if mime_parser.incoming {
430-
res = handle_securejoin_handshake(context, &mut mime_parser, from_id)
428+
let res = if mime_parser.incoming {
429+
handle_securejoin_handshake(context, &mut mime_parser, from_id)
431430
.await
432-
.context("error in Secure-Join message handling")?;
431+
.context("error in Secure-Join message handling")?
433432
} else {
434433
let to_id = to_ids.first().copied().flatten().unwrap_or(ContactId::SELF);
435434
// handshake may mark contacts as verified and must be processed before chats are created
436-
res = observe_securejoin_on_other_device(context, &mime_parser, to_id)
435+
observe_securejoin_on_other_device(context, &mime_parser, to_id)
437436
.await
438437
.context("error in Secure-Join watching")?
439-
}
438+
};
440439

441440
match res {
442441
securejoin::HandshakeMessage::Done | securejoin::HandshakeMessage::Ignore => {

src/securejoin/securejoin_tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
350350

351351
tcm.section("Step 1: Generate QR-code");
352352
// `None` indicates setup-contact.
353-
let qr = get_securejoin_qr(&alice, None).await?;
353+
let qr = get_securejoin_qr(alice, None).await?;
354354

355355
tcm.section("Step 2+4: Bob scans QR-code, sends vc-request-with-auth, skipping vc-request");
356-
join_securejoin(&bob, &qr).await.unwrap();
356+
join_securejoin(bob, &qr).await.unwrap();
357357

358358
// Check Bob emitted the JoinerProgress event.
359359
let event = bob
@@ -388,11 +388,11 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
388388

389389
// Alice should not yet have Bob verified
390390
let contact_bob = alice.add_or_lookup_pgp_contact(bob).await;
391-
assert_eq!(contact_bob.is_verified(&alice).await?, false);
391+
assert_eq!(contact_bob.is_verified(alice).await?, false);
392392

393393
tcm.section("Step 5+6: Alice receives vc-request-with-auth, sends vc-contact-confirm");
394394
alice.recv_msg_trash(&sent).await;
395-
assert_eq!(contact_bob.is_verified(&alice).await?, true);
395+
assert_eq!(contact_bob.is_verified(alice).await?, true);
396396

397397
let sent = alice.pop_sent_msg().await;
398398
let msg = bob.parse_msg(&sent).await;

src/tests/aeap.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,29 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition, verified:
8181
}
8282

8383
let mut groups = vec![
84-
chat::create_group_chat(&bob, chat::ProtectionStatus::Unprotected, "Group 0")
84+
chat::create_group_chat(bob, chat::ProtectionStatus::Unprotected, "Group 0")
8585
.await
8686
.unwrap(),
87-
chat::create_group_chat(&bob, chat::ProtectionStatus::Unprotected, "Group 1")
87+
chat::create_group_chat(bob, chat::ProtectionStatus::Unprotected, "Group 1")
8888
.await
8989
.unwrap(),
9090
];
9191
if verified {
9292
groups.push(
93-
chat::create_group_chat(&bob, chat::ProtectionStatus::Protected, "Group 2")
93+
chat::create_group_chat(bob, chat::ProtectionStatus::Protected, "Group 2")
9494
.await
9595
.unwrap(),
9696
);
9797
groups.push(
98-
chat::create_group_chat(&bob, chat::ProtectionStatus::Protected, "Group 3")
98+
chat::create_group_chat(bob, chat::ProtectionStatus::Protected, "Group 3")
9999
.await
100100
.unwrap(),
101101
);
102102
}
103103

104-
let alice_contact = bob.add_or_lookup_contact_id(&alice).await;
104+
let alice_contact = bob.add_or_lookup_contact_id(alice).await;
105105
for group in &groups {
106-
chat::add_contact_to_chat(&bob, *group, alice_contact)
106+
chat::add_contact_to_chat(bob, *group, alice_contact)
107107
.await
108108
.unwrap();
109109
}
@@ -121,12 +121,12 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition, verified:
121121
group3_alice = Some(alice.recv_msg(&sent).await.chat_id);
122122
}
123123

124-
tcm.change_addr(&alice, ALICE_NEW_ADDR).await;
124+
tcm.change_addr(alice, ALICE_NEW_ADDR).await;
125125

126126
tcm.section("Alice sends another message to Bob, this time from her new addr");
127127
// No matter which chat Alice sends to, the transition should be done in all groups
128128
let chat_to_send = match chat_for_transition {
129-
OneToOne => alice.create_chat(&bob).await.id,
129+
OneToOne => alice.create_chat(bob).await.id,
130130
GroupChat => group1_alice,
131131
VerifiedGroup => group3_alice.expect("No verified group"),
132132
};
@@ -141,7 +141,7 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition, verified:
141141
check_that_transition_worked(bob, &groups, alice_contact, ALICE_NEW_ADDR).await;
142142

143143
tcm.section("Test switching back");
144-
tcm.change_addr(&alice, "[email protected]").await;
144+
tcm.change_addr(alice, "[email protected]").await;
145145
let sent = alice
146146
.send_text(chat_to_send, "Hello from my old addr!")
147147
.await;

0 commit comments

Comments
 (0)