From d6748880f11710d84df9c5705611ab4fa909d942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jagoda=20=C5=9Al=C4=85zak?= Date: Thu, 23 Jul 2026 10:25:27 +0200 Subject: [PATCH] refactor: Unify naming of direct/single/1:1/normal chats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unifies internal naming of single/direct/1:1/normal chats to match the naming used in the API. Closes: #8368 Signed-off-by: Jagoda Ślązak --- deltachat-jsonrpc/src/api.rs | 4 +- deltachat-jsonrpc/src/api/types/message.rs | 4 +- .../src/deltachat_rpc_client/chat.py | 2 +- .../src/deltachat_rpc_client/const.py | 2 +- python/src/deltachat/chat.py | 2 +- src/calls.rs | 2 +- src/chat.rs | 40 +++++----- src/chat/chat_tests.rs | 54 ++++++------- src/chatlist.rs | 16 ++-- src/constants.rs | 2 +- src/contact.rs | 2 +- src/contact/contact_tests.rs | 2 +- src/ephemeral.rs | 2 +- src/events/chatlist_events.rs | 2 +- src/message/message_tests.rs | 10 +-- src/mimeparser.rs | 4 +- src/receive_imf.rs | 78 +++++++++---------- src/receive_imf/receive_imf_tests.rs | 36 ++++----- src/securejoin.rs | 2 +- src/securejoin/bob.rs | 14 ++-- src/securejoin/securejoin_tests.rs | 12 +-- src/sql/migrations.rs | 6 +- src/stats.rs | 20 ++--- src/test_utils.rs | 26 +++---- src/tests/aeap.rs | 8 +- src/tests/verified_chats.rs | 18 ++--- 26 files changed, 180 insertions(+), 190 deletions(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 788a220f70..5b3a1b4f32 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -875,7 +875,7 @@ impl CommandApi { /// - The chat or the contact is **not blocked**, so new messages from the user/the group may appear as a contact request /// and the user may create the chat again. /// - **Groups are not left** - this would - /// be unexpected as (1) deleting a normal chat also does not prevent new mails + /// be unexpected as (1) deleting a single chat also does not prevent new mails /// from arriving, (2) leaving a group requires sending a message to /// all group members - especially for groups not used for a longer time, this is /// really unexpected when deletion results in contacting all members again, @@ -1040,7 +1040,7 @@ impl CommandApi { /// Get the contact IDs belonging to a chat. /// - /// - for normal chats, the function always returns exactly one contact, + /// - for single chats, the function always returns exactly one contact, /// DC_CONTACT_ID_SELF is returned only for SELF-chats. /// /// - for group chats all members are returned, DC_CONTACT_ID_SELF is returned diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index 2b37fb507d..a63304a9cc 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -390,11 +390,11 @@ pub enum SystemMessageType { LocationOnly, InvalidUnencryptedMail, - /// 1:1 chats info message telling that SecureJoin has started and the user should wait for it + /// Single chats info message telling that SecureJoin has started and the user should wait for it /// to complete. SecurejoinWait, - /// 1:1 chats info message telling that SecureJoin is still running, but the user may already + /// Single chats info message telling that SecureJoin is still running, but the user may already /// send messages. SecurejoinWaitTimeout, diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/chat.py b/deltachat-rpc-client/src/deltachat_rpc_client/chat.py index 390f6fac11..bc35f77d70 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/chat.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/chat.py @@ -252,7 +252,7 @@ def remove_contact(self, *contact: Union[int, str, Contact, "Account"]) -> None: def get_contacts(self) -> list[Contact]: """Get the contacts belonging to this chat. - For single/direct chats self-address is not included. + For single chats self-address is not included. """ contacts = self._rpc.get_chat_contacts(self.account.id, self.id) return [Contact(self.account, contact_id) for contact_id in contacts] diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/const.py b/deltachat-rpc-client/src/deltachat_rpc_client/const.py index 581cf56a4c..c93424c463 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/const.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/const.py @@ -97,7 +97,7 @@ class ChatType(str, Enum): """Chat type.""" SINGLE = "Single" - """1:1 chat, i.e. a direct chat with a single contact""" + """Single chat (a chat with a with a single contact)""" GROUP = "Group" diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index e9d15ac670..1297713b1f 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -74,7 +74,7 @@ def is_group(self) -> bool: return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_GROUP def is_single(self) -> bool: - """Return True if this chat is a single/direct chat, False otherwise.""" + """Return True if this chat is a single chat, False otherwise.""" return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_SINGLE def is_mailinglist(self) -> bool: diff --git a/src/calls.rs b/src/calls.rs index f61219dffb..fad239a5ab 100644 --- a/src/calls.rs +++ b/src/calls.rs @@ -201,7 +201,7 @@ impl Context { let chat = Chat::load_from_db(self, chat_id).await?; ensure!( chat.typ == Chattype::Single, - "Can only place calls in 1:1 chats" + "Can only place calls in single chats" ); ensure!(!chat.is_self_talk(), "Cannot call self"); diff --git a/src/chat.rs b/src/chat.rs index 8c6f66e14c..ec73eddfe6 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -97,7 +97,7 @@ pub(crate) enum CantSendReason { /// Not a member of the chat. NotAMember, - /// State for 1:1 chat with a key-contact that does not have a key. + /// State for single chat with a key-contact that does not have a key. MissingKey, } @@ -194,7 +194,7 @@ impl ChatId { Some(msg.chat_id) } - /// Returns the [`ChatId`] for the 1:1 chat with `contact_id` + /// Returns the [`ChatId`] for the single chat with `contact_id` /// if it exists and is not blocked. /// /// If the chat does not exist or is blocked, `None` is returned. @@ -214,7 +214,7 @@ impl ChatId { Ok(chat_id) } - /// Returns the [`ChatId`] for the 1:1 chat with `contact_id`. + /// Returns the [`ChatId`] for the single chat with `contact_id`. /// /// If the chat does not yet exist an unblocked chat ([`Blocked::Not`]) is created. /// @@ -227,9 +227,9 @@ impl ChatId { .map(|chat| chat.id) } - /// Returns the unblocked 1:1 chat with `contact_id`. + /// Returns the unblocked single chat with `contact_id`. /// - /// This should be used when **a user action** creates a chat 1:1, it ensures the chat + /// This should be used when **a user action** creates a single chat, it ensures the chat /// exists, is unblocked and scales the [`Contact`]'s origin. pub async fn create_for_contact(context: &Context, contact_id: ContactId) -> Result { ChatId::create_for_contact_with_blocked(context, contact_id, Blocked::Not).await @@ -374,7 +374,7 @@ impl ChatId { if contact_id != ContactId::SELF { info!( context, - "Blocking the contact {contact_id} to block 1:1 chat." + "Blocking the contact {contact_id} to block a single chat." ); contact::set_blocked(context, Nosync, contact_id, true).await?; } @@ -393,7 +393,7 @@ impl ChatId { chatlist_events::emit_chatlist_changed(context); if sync.into() { - // NB: For a 1:1 chat this currently triggers `Contact::block()` on other devices. + // NB: For a single chat this currently triggers `Contact::block()` on other devices. chat.sync(context, SyncAction::Block) .await .log_err(context) @@ -417,7 +417,7 @@ impl ChatId { if sync.into() { let chat = Chat::load_from_db(context, self).await?; - // TODO: For a 1:1 chat this currently triggers `Contact::unblock()` on other devices. + // TODO: For a single chat this currently triggers `Contact::unblock()` on other devices. // Maybe we should unblock the contact locally too, this would also resolve discrepancy // with `block()` which also blocks the contact. chat.sync(context, SyncAction::Unblock) @@ -1154,7 +1154,7 @@ SELECT id, rfc724_mid, pre_rfc724_mid, timestamp, ?, 1 FROM msgs WHERE chat_id=? MessageState::InSeen as u32, state_out_min as u32, // Do not reply to not fully downloaded messages. Such a message could be a group chat - // message that we assigned to 1:1 chat. + // message that we assigned to a single chat. DownloadState::Done as u32, // Do not reference info messages, they are not actually sent out // and have Message-IDs unknown to other chat members. @@ -1347,7 +1347,7 @@ pub struct Chat { /// Database ID. pub id: ChatId, - /// Chat type, e.g. 1:1 chat, group chat, mailing list. + /// Chat type, e.g. a single chat, group chat, mailing list. pub typ: Chattype, /// Chat name. @@ -1356,7 +1356,7 @@ pub struct Chat { /// Whether the chat is archived or pinned. pub visibility: ChatVisibility, - /// Group ID. For [`Chattype::Mailinglist`] -- mailing list address. Empty for 1:1 chats and + /// Group ID. For [`Chattype::Mailinglist`] -- mailing list address. Empty for single chats and /// ad-hoc groups. pub grpid: String, @@ -1584,7 +1584,7 @@ impl Chat { Path::new(&get_unencrypted_icon(context).await?), ))); } else if self.typ == Chattype::Single { - // For 1:1 chats, we always use the same avatar as for the contact + // For single chats, we always use the same avatar as for the contact // This is before the `self.is_encrypted()` check, because that function // has two database calls, i.e. it's slow let contacts = get_chat_contacts(context, self.id).await?; @@ -1603,7 +1603,7 @@ impl Chat { /// Returns chat avatar color. /// - /// For 1:1 chats, the color is calculated from the contact's address + /// For single chats, the color is calculated from the contact's address /// for address-contacts and from the OpenPGP key fingerprint for key-contacts. /// For group chats the color is calculated from the grpid, if present, or the chat name. pub async fn get_color(&self, context: &Context) -> Result { @@ -2338,7 +2338,7 @@ pub(crate) struct ChatIdBlocked { } impl ChatIdBlocked { - /// Searches the database for the 1:1 chat with this contact. + /// Searches the database for the single chat with this contact. /// /// If no chat is found `None` is returned. pub async fn lookup_by_contact( @@ -2371,7 +2371,7 @@ impl ChatIdBlocked { .await } - /// Returns the chat for the 1:1 chat with this contact. + /// Returns the chat for the single chat with this contact. /// /// If the chat does not yet exist a new one is created, using the provided [`Blocked`] /// state. @@ -2579,11 +2579,11 @@ pub async fn is_contact_in_chat( chat_id: ChatId, contact_id: ContactId, ) -> Result { - // this function works for group and for normal chats, however, it is more useful + // this function works for group and for single chats, however, it is more useful // for group chats. // ContactId::SELF may be used to check whether oneself // is in a group or incoming broadcast chat - // (ContactId::SELF is not added to 1:1 chats or outgoing broadcast channels) + // (ContactId::SELF is not added to single chats or outgoing broadcast channels) let exists = context .sql @@ -3492,7 +3492,7 @@ pub async fn get_chat_media( /// Returns a vector of contact IDs for given chat ID. pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result> { - // Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a + // Single chats do not include SELF. Group chats do (as it may happen that one is deleted from a // groupchat but the chats stays visible, moreover, this makes displaying lists easier) context .sql @@ -3876,7 +3876,7 @@ pub(crate) async fn add_contact_to_chat_ex( chat_id.reset_gossiped_timestamp(context).await?; - // this also makes sure, no contacts are added to special or normal chats + // this also makes sure, no contacts are added to special or single chats let mut chat = Chat::load_from_db(context, chat_id).await?; ensure!( chat.typ == Chattype::Group || (from_handshake && chat.typ == Chattype::OutBroadcast), @@ -4349,7 +4349,7 @@ async fn rename_ex( new_name: &str, ) -> Result<()> { let new_name = sanitize_single_line(new_name); - /* the function only sets the names of group chats; normal chats get their names from the contacts */ + /* the function only sets the names of group chats; single chats get their names from the contacts */ let mut success = false; ensure!(!new_name.is_empty(), "Invalid name"); diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index a27b706701..abb1eaae1c 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -259,9 +259,9 @@ async fn test_quote_replies() -> Result<()> { let grp_msg_id = send_text_msg(&alice, grp_chat_id, "bar".to_string()).await?; let grp_msg = Message::load_from_db(&alice, grp_msg_id).await?; - let one2one_chat_id = alice.create_chat(&bob).await.id; - let one2one_msg_id = send_text_msg(&alice, one2one_chat_id, "foo".to_string()).await?; - let one2one_msg = Message::load_from_db(&alice, one2one_msg_id).await?; + let single_chat_id = alice.create_chat(&bob).await.id; + let single_chat_msg_id = send_text_msg(&alice, single_chat_id, "foo".to_string()).await?; + let single_chat_msg = Message::load_from_db(&alice, single_chat_msg_id).await?; // quoting messages in same chat is okay let mut msg = Message::new_text("baz".to_string()); @@ -270,25 +270,25 @@ async fn test_quote_replies() -> Result<()> { assert!(result.is_ok()); let mut msg = Message::new_text("baz".to_string()); - msg.set_quote(&alice, Some(&one2one_msg)).await?; - let result = send_msg(&alice, one2one_chat_id, &mut msg).await; + msg.set_quote(&alice, Some(&single_chat_msg)).await?; + let result = send_msg(&alice, single_chat_id, &mut msg).await; assert!(result.is_ok()); - let one2one_quote_reply_msg_id = result.unwrap(); + let single_chat_quote_reply_msg_id = result.unwrap(); - // quoting messages from groups to one-to-ones is okay ("reply privately") + // quoting messages from groups to single chats is okay ("reply privately") let mut msg = Message::new_text("baz".to_string()); msg.set_quote(&alice, Some(&grp_msg)).await?; - let result = send_msg(&alice, one2one_chat_id, &mut msg).await; + let result = send_msg(&alice, single_chat_id, &mut msg).await; assert!(result.is_ok()); - // quoting messages from one-to-one chats in groups is an error; usually this is also not allowed by UI at all ... + // quoting messages from single chats in groups is an error; usually this is also not allowed by UI at all ... let mut msg = Message::new_text("baz".to_string()); - msg.set_quote(&alice, Some(&one2one_msg)).await?; + msg.set_quote(&alice, Some(&single_chat_msg)).await?; let result = send_msg(&alice, grp_chat_id, &mut msg).await; assert!(result.is_err()); // ... but forwarding messages with quotes is allowed - let result = forward_msgs(&alice, &[one2one_quote_reply_msg_id], grp_chat_id).await; + let result = forward_msgs(&alice, &[single_chat_quote_reply_msg_id], grp_chat_id).await; assert!(result.is_ok()); // ... and bots are not restricted @@ -775,7 +775,7 @@ async fn test_leave_group() -> Result<()> { Ok(()) } -/// Test that adding or removing contacts in 1:1 chat is not allowed. +/// Test that adding or removing contacts in single chat is not allowed. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_add_remove_contact_for_single() { let ctx = TestContext::new_alice().await; @@ -785,7 +785,7 @@ async fn test_add_remove_contact_for_single() { assert_eq!(chat.typ, Chattype::Single); assert_eq!(get_chat_contacts(&ctx, chat.id).await.unwrap().len(), 1); - // adding or removing contacts from one-to-one-chats result in an error + // adding or removing contacts from single chats result in an error let claire = Contact::create(&ctx, "", "claire@foo.de").await.unwrap(); let added = add_contact_to_chat_ex(&ctx, Nosync, chat.id, claire, false).await; assert!(added.is_err()); @@ -3624,7 +3624,7 @@ async fn test_broadcast_joining_golden() -> Result<()> { .await; let alice_bob_contact = alice.add_or_lookup_contact_no_key(bob).await; - // The 1:1 chat with Bob should not be visible to the user: + // The single chat with Bob should not be visible to the user: assert!( ChatIdBlocked::lookup_by_contact(alice, alice_bob_contact.id) .await? @@ -3937,11 +3937,11 @@ async fn test_leave_broadcast_multidevice() -> Result<()> { bob1.recv_msg_trash(&request_with_auth).await; bob1.recv_msg(&member_added).await; - // The 1:1 chat should not be visible to the user on any of the devices. + // The single chat should not be visible to the user on any of the devices. // The contact should be marked as verified. - check_direct_chat_is_hidden_and_contact_is_verified(alice, bob0).await; - check_direct_chat_is_hidden_and_contact_is_verified(bob0, alice).await; - check_direct_chat_is_hidden_and_contact_is_verified(bob1, alice).await; + check_single_chat_is_hidden_and_contact_is_verified(alice, bob0).await; + check_single_chat_is_hidden_and_contact_is_verified(bob0, alice).await; + check_single_chat_is_hidden_and_contact_is_verified(bob1, alice).await; tcm.section("Alice sends first message to broadcast."); let sent_msg = alice.send_text(alice_chat_id, "Hello!").await; @@ -3968,16 +3968,16 @@ async fn test_leave_broadcast_multidevice() -> Result<()> { Ok(()) } -async fn check_direct_chat_is_hidden_and_contact_is_verified( +async fn check_single_chat_is_hidden_and_contact_is_verified( t: &TestContext, contact: &TestContext, ) { let contact = t.add_or_lookup_contact_no_key(contact).await; - if let Some(direct_chat) = ChatIdBlocked::lookup_by_contact(t, contact.id) + if let Some(single_chat) = ChatIdBlocked::lookup_by_contact(t, contact.id) .await .unwrap() { - assert_eq!(direct_chat.blocked, Blocked::Yes); + assert_eq!(single_chat.blocked, Blocked::Yes); } assert!(contact.is_verified(t).await.unwrap()); } @@ -4020,7 +4020,7 @@ async fn test_only_broadcast_owner_can_send_1() -> Result<()> { .await?; tcm.section( - "Bob receives an answer, but shows it in 1:1 chat because of a fingerprint mismatch", + "Bob receives an answer, but shows it in a single chat because of a fingerprint mismatch", ); let rcvd = bob.recv_msg(&member_added).await; assert_eq!(rcvd.text, "Member bob@example.net was added."); @@ -4607,7 +4607,7 @@ async fn test_sync_blocked() -> Result<()> { sync(alice0, alice1).await; assert_eq!(alice1.get_chat(bob).await.blocked, Blocked::Not); - // Unblocking a 1:1 chat doesn't unblock the contact currently. + // Unblocking a single chat doesn't unblock the contact currently. Contact::unblock(alice0, a0b_contact_id).await?; assert!(!alice1.add_or_lookup_contact(bob).await.is_blocked()); @@ -5153,7 +5153,7 @@ async fn test_blocked_bob_cant_join_chat() -> Result<()> { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_blocked_bob_cant_create_11_chat_via_securejoin() -> Result<()> { +async fn test_blocked_bob_cant_create_single_chat_via_securejoin() -> Result<()> { let mut tcm = TestContextManager::new(); let alice1 = &tcm.alice().await; let alice2 = &tcm.alice().await; @@ -5834,7 +5834,7 @@ async fn test_restore_backup_after_60_days() -> Result<()> { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_one_to_one_chat_no_group_member_timestamps() { +async fn test_single_chat_no_group_member_timestamps() { let t = TestContext::new_alice().await; t.allow_unencrypted().await.unwrap(); let chat = t.create_chat_with_contact("bob", "bob@example.com").await; @@ -6225,9 +6225,9 @@ async fn test_forward_msgs_2ctx_missing_blob() -> Result<()> { /// Tests that in multi-device setup /// second device learns the key of a contact -/// via Autocrypt-Gossip in 1:1 chats. +/// via Autocrypt-Gossip in single chats. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_oneone_gossip() -> Result<()> { +async fn test_single_gossip() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let alice2 = &tcm.alice().await; diff --git a/src/chatlist.rs b/src/chatlist.rs index 17f20fcc3b..aaefe1b31a 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -653,7 +653,7 @@ mod tests { let t = TestContext::new_alice().await; t.allow_unencrypted().await?; - // receive a one-to-one-message + // receive a single chat message receive_imf( &t, b"From: Bob Authname \n\ @@ -681,12 +681,12 @@ mod tests { let chat = Chat::load_from_db(&t, chat_id).await?; assert_eq!(chat.get_name(), "Bob Authname"); - // check, the one-to-one-chat can be found using chatlist search query + // check, the single chat can be found using chatlist search query let chats = Chatlist::try_load(&t, 0, Some("bob authname"), None).await?; assert_eq!(chats.len(), 1); assert_eq!(chats.get_chat_id(0).unwrap(), chat_id); - // change the name of the contact; this also changes the name of the one-to-one-chat + // change the name of the contact; this also changes the name of the single chat let test_id = Contact::create(&t, "Bob Nickname", "bob@example.org").await?; assert_eq!(contact_id, test_id); let chat = Chat::load_from_db(&t, chat_id).await?; @@ -696,7 +696,7 @@ mod tests { let chats = Chatlist::try_load(&t, 0, Some("bob nickname"), None).await?; assert_eq!(chats.len(), 1); - // revert contact to authname, this again changes the name of the one-to-one-chat + // revert contact to authname, this again changes the name of the single chat let test_id = Contact::create(&t, "", "bob@example.org").await?; assert_eq!(contact_id, test_id); let chat = Chat::load_from_db(&t, chat_id).await?; @@ -714,7 +714,7 @@ mod tests { let t = TestContext::new_alice().await; t.allow_unencrypted().await?; - // receive a one-to-one-message without authname set + // receive a single chat message without authname set receive_imf( &t, b"From: bob@example.org\n\ @@ -737,12 +737,12 @@ mod tests { let chat = Chat::load_from_db(&t, chat_id).await?; assert_eq!(chat.get_name(), "bob@example.org"); - // check, the one-to-one-chat can be found using chatlist search query + // check, the single chat can be found using chatlist search query let chats = Chatlist::try_load(&t, 0, Some("bob@example.org"), None).await?; assert_eq!(chats.len(), 1); assert_eq!(chats.get_chat_id(0)?, chat_id); - // change the name of the contact; this also changes the name of the one-to-one-chat + // change the name of the contact; this also changes the name of the single chat let test_id = Contact::create(&t, "Bob Nickname", "bob@example.org").await?; assert_eq!(contact_id, test_id); let chat = Chat::load_from_db(&t, chat_id).await?; @@ -753,7 +753,7 @@ mod tests { assert_eq!(chats.len(), 1); assert_eq!(chats.get_chat_id(0)?, chat_id); - // revert name change, this again changes the name of the one-to-one-chat to the email-address + // revert name change, this again changes the name of the single chat to the email-address let test_id = Contact::create(&t, "", "bob@example.org").await?; assert_eq!(contact_id, test_id); let chat = Chat::load_from_db(&t, chat_id).await?; diff --git a/src/constants.rs b/src/constants.rs index 456dea21f6..d8b973c2d3 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -99,7 +99,7 @@ pub const DC_CHAT_ID_LAST_SPECIAL: ChatId = ChatId::new(9); )] #[repr(u32)] pub enum Chattype { - /// A 1:1 chat, i.e. a normal chat with a single contact. + /// A single chat (a chat with a single contact). /// /// Created by [`ChatId::create_for_contact`]. Single = 100, diff --git a/src/contact.rs b/src/contact.rs index 310600c96a..47bc5c3073 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1856,7 +1856,7 @@ pub(crate) async fn set_blocked( // also (un)block all chats with _only_ this contact - we do not delete them to allow a // non-destructive blocking->unblocking. - // (Maybe, beside normal chats (type=100) we should also block group chats with only this user. + // (Maybe, beside single chats (type=100) we should also block group chats with only this user. // However, I'm not sure about this point; it may be confusing if the user wants to add other people; // this would result in recreating the same group...) if context diff --git a/src/contact/contact_tests.rs b/src/contact/contact_tests.rs index fbdf8133c0..44a62253fd 100644 --- a/src/contact/contact_tests.rs +++ b/src/contact/contact_tests.rs @@ -337,7 +337,7 @@ async fn test_contact_name_changes() -> Result<()> { let t = TestContext::new_alice().await; t.allow_unencrypted().await?; - // first message creates contact and one-to-one-chat without name set + // first message creates contact and single-chat without name set receive_imf( &t, b"From: f@example.org\n\ diff --git a/src/ephemeral.rs b/src/ephemeral.rs index d9ea5b16b5..63f6e89fc3 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -7,7 +7,7 @@ //! seen, which usually happens when its contents is displayed on //! device screen. //! -//! Each chat, including 1:1, group chats and "saved messages" chat, +//! Each chat, including single, group chats and "saved messages" chat, //! has its own ephemeral timer setting, which is applied to all //! messages sent to the chat. The setting is synchronized to all the //! devices participating in the chat by applying the timer value from diff --git a/src/events/chatlist_events.rs b/src/events/chatlist_events.rs index ec909a12f4..16d57e5f69 100644 --- a/src/events/chatlist_events.rs +++ b/src/events/chatlist_events.rs @@ -21,7 +21,7 @@ fn emit_unknown_chatlist_items_changed(context: &Context) { context.emit_event(EventType::ChatlistItemChanged { chat_id: None }); } -/// update event for the 1:1 chat with the contact +/// update event for the single chat with the contact /// used when recently seen changes and when profile image changes pub(crate) async fn emit_chatlist_item_changed_for_contact_chat( context: &Context, diff --git a/src/message/message_tests.rs b/src/message/message_tests.rs index 407e247e43..13593b57bb 100644 --- a/src/message/message_tests.rs +++ b/src/message/message_tests.rs @@ -212,8 +212,8 @@ async fn test_get_original_msg_id() -> Result<()> { let bob = TestContext::new_bob().await; // normal sending of messages does not have an original ID - let one2one_chat = alice.create_chat(&bob).await; - let sent = alice.send_text(one2one_chat.id, "foo").await; + let single_chat = alice.create_chat(&bob).await; + let sent = alice.send_text(single_chat.id, "foo").await; let orig_msg = Message::load_from_db(&alice, sent.sender_msg_id).await?; assert!(orig_msg.get_original_msg_id(&alice).await?.is_none()); assert!(orig_msg.parent(&alice).await?.is_none()); @@ -232,8 +232,8 @@ async fn test_get_original_msg_id() -> Result<()> { assert!(saved_msg.quoted_message(&alice).await?.is_none()); // forwarding from "Saved Messages" back to another chat, detaches original ID - forward_msgs(&alice, &[saved_msg.get_id()], one2one_chat.get_id()).await?; - let forwarded_msg = alice.get_last_msg_in(one2one_chat.get_id()).await; + forward_msgs(&alice, &[saved_msg.get_id()], single_chat.get_id()).await?; + let forwarded_msg = alice.get_last_msg_in(single_chat.get_id()).await; assert_ne!(forwarded_msg.get_id(), saved_msg.get_id()); assert_ne!(forwarded_msg.get_id(), orig_msg.get_id()); assert!(forwarded_msg.get_original_msg_id(&alice).await?.is_none()); @@ -275,7 +275,7 @@ async fn test_markseen_msgs() -> Result<()> { bob_chat_id.accept(&bob).await.unwrap(); // bob sends to alice, - // alice knows bob and messages appear in normal chat + // alice knows bob and messages appear in single chat let mut msg = Message::new_text("this is the text!".to_string()); let msg1 = alice .recv_msg(&bob.send_msg(bob_chat_id, &mut msg).await) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index af93301ad8..5eed0e5c20 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -225,11 +225,11 @@ pub enum SystemMessage { /// which is sent by chatmail servers. InvalidUnencryptedMail = 13, - /// 1:1 chats info message telling that SecureJoin has started and the user should wait for it + /// Single chats info message telling that SecureJoin has started and the user should wait for it /// to complete. SecurejoinWait = 14, - /// 1:1 chats info message telling that SecureJoin is still running, but the user may already + /// Single chats info message telling that SecureJoin is still running, but the user may already /// send messages. SecurejoinWaitTimeout = 15, diff --git a/src/receive_imf.rs b/src/receive_imf.rs index c4dbc87fb8..20d1b76cc2 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -143,14 +143,14 @@ enum ChatAssignment { chat_id_blocked: Blocked, }, - /// 1:1 chat with a single contact. + /// Single chat with a single contact. /// /// The chat may be encrypted or not, /// it does not matter. /// It is not possible to mix /// email address contacts - /// with key-contacts in a single 1:1 chat anyway. - OneOneChat, + /// with key-contacts in a single chat anyway. + SingleChat, } /// Emulates reception of a message from the network. @@ -208,7 +208,7 @@ async fn get_to_and_past_contact_ids( // Note that this is not necessarily the chat we want to assign the message to. // In case of an outgoing private reply to a group message we may // lookup the address of receipient in the list of addresses used in the group, - // but want to assign the message to 1:1 chat. + // but want to assign the message to a single chat. let chat_id = match chat_assignment { ChatAssignment::Trash => None, ChatAssignment::GroupChat { grpid } => { @@ -227,7 +227,7 @@ async fn get_to_and_past_contact_ids( } ChatAssignment::ExistingChat { chat_id, .. } => Some(*chat_id), ChatAssignment::MailingListOrBroadcast => None, - ChatAssignment::OneOneChat => { + ChatAssignment::SingleChat => { if !mime_parser.incoming { parent_message.as_ref().map(|m| m.chat_id) } else { @@ -356,8 +356,8 @@ async fn get_to_and_past_contact_ids( } // Sometimes, messages are sent just to a single recipient // in a broadcast (e.g. securejoin messages). - // In this case, we need to look them up like in a 1:1 chat: - ChatAssignment::OneOneChat | ChatAssignment::MailingListOrBroadcast => { + // In this case, we need to look them up like in a single chat: + ChatAssignment::SingleChat | ChatAssignment::MailingListOrBroadcast => { let pgp_to_ids = add_or_lookup_key_contacts( context, &mime_parser.recipients, @@ -372,7 +372,7 @@ async fn get_to_and_past_contact_ids( { // There is a single recipient and we have // mapped it to a key contact. - // This is an encrypted 1:1 chat. + // This is an encrypted single chat. to_ids = pgp_to_ids } else { let ids = if mime_parser.was_encrypted() { @@ -612,7 +612,7 @@ pub(crate) async fn receive_imf_inner( // // This can be also used to lookup // key-contact by email address - // when receiving a private 1:1 reply + // when receiving a single chat reply // to a group chat message. let parent_message = get_parent_message( context, @@ -1327,12 +1327,12 @@ async fn decide_chat_assignment( num_recipients += 1; } } - let mut can_be_11_chat_log = String::new(); + let mut can_be_single_chat_log = String::new(); let mut l = |cond: bool, s: String| { - can_be_11_chat_log += &s; + can_be_single_chat_log += &s; cond }; - let can_be_11_chat = l( + let can_be_single_chat = l( num_recipients <= 1, format!("num_recipients={num_recipients}."), ) && (l(from_id != ContactId::SELF, format!(" from_id={from_id}.")) @@ -1396,21 +1396,21 @@ async fn decide_chat_assignment( } else if mime_parser.get_header(HeaderDef::ChatGroupName).is_some() { chat_assignment_log = "Reply with Chat-Group-Name.".to_string(); ChatAssignment::AdHocGroup - } else if can_be_11_chat { - chat_assignment_log = format!("Non-group reply. {can_be_11_chat_log}"); - ChatAssignment::OneOneChat + } else if can_be_single_chat { + chat_assignment_log = format!("Non-group reply. {can_be_single_chat_log}"); + ChatAssignment::SingleChat } else { - chat_assignment_log = format!("Non-group reply. {can_be_11_chat_log}"); + chat_assignment_log = format!("Non-group reply. {can_be_single_chat_log}"); ChatAssignment::AdHocGroup } } else if mime_parser.get_header(HeaderDef::ChatGroupName).is_some() { chat_assignment_log = "Message with Chat-Group-Name, no parent.".to_string(); ChatAssignment::AdHocGroup - } else if can_be_11_chat { - chat_assignment_log = format!("Non-group message, no parent. {can_be_11_chat_log}"); - ChatAssignment::OneOneChat + } else if can_be_single_chat { + chat_assignment_log = format!("Non-group message, no parent. {can_be_single_chat_log}"); + ChatAssignment::SingleChat } else { - chat_assignment_log = format!("Non-group message, no parent. {can_be_11_chat_log}"); + chat_assignment_log = format!("Non-group message, no parent. {can_be_single_chat_log}"); ChatAssignment::AdHocGroup }; @@ -1450,14 +1450,14 @@ async fn do_chat_assignment( let mut chat_created = false; if mime_parser.incoming { - let test_normal_chat = ChatIdBlocked::lookup_by_contact(context, from_id).await?; + let test_single_chat = ChatIdBlocked::lookup_by_contact(context, from_id).await?; let create_blocked_default = if is_bot { Blocked::Not } else { Blocked::Request }; - let create_blocked = if let Some(ChatIdBlocked { id: _, blocked }) = test_normal_chat { + let create_blocked = if let Some(ChatIdBlocked { id: _, blocked }) = test_single_chat { match blocked { Blocked::Request => create_blocked_default, Blocked::Not => Blocked::Not, @@ -1467,8 +1467,8 @@ async fn do_chat_assignment( // Block the group contact created as well. Blocked::Yes } else { - // 1:1 chat is blocked, but the contact is not. - // This happens when 1:1 chat is hidden + // Single chat is blocked, but the contact is not. + // This happens when single chat is hidden // during scanning of a group invitation code. create_blocked_default } @@ -1487,7 +1487,7 @@ async fn do_chat_assignment( if let Some((id, blocked)) = chat::get_chat_id_by_grpid(context, grpid).await? { chat_id = Some(id); chat_id_blocked = blocked; - } else if (allow_creation || test_normal_chat.is_some()) + } else if (allow_creation || test_single_chat.is_some()) && let Some((new_chat_id, new_chat_id_blocked)) = create_group( context, mime_parser, @@ -1537,7 +1537,7 @@ async fn do_chat_assignment( context, mime_parser, to_ids, - allow_creation || test_normal_chat.is_some(), + allow_creation || test_single_chat.is_some(), create_blocked, ) .await? @@ -1547,7 +1547,7 @@ async fn do_chat_assignment( chat_created = new_created; } } - ChatAssignment::OneOneChat => {} + ChatAssignment::SingleChat => {} } // if the chat is somehow blocked but we want to create a non-blocked chat, @@ -1562,7 +1562,7 @@ async fn do_chat_assignment( } if chat_id.is_none() { - // Try to create a 1:1 chat. + // Try to create a single chat. let contact = Contact::get_by_id(context, from_id).await?; let create_blocked = match contact.is_blocked() { true => Blocked::Yes, @@ -1570,7 +1570,7 @@ async fn do_chat_assignment( false => Blocked::Request, }; - if let Some(chat) = test_normal_chat { + if let Some(chat) = test_single_chat { chat_id = Some(chat.id); chat_id_blocked = chat.blocked; } else if allow_creation { @@ -1691,7 +1691,7 @@ async fn do_chat_assignment( chat_created = new_chat_created; } } - ChatAssignment::OneOneChat => {} + ChatAssignment::SingleChat => {} } if !to_ids.is_empty() { @@ -1803,10 +1803,10 @@ async fn add_parts( context, "Not assigning msg '{rfc724_mid}' to broadcast {chat_id}: wrong sender: {from_id}." ); - let direct_chat = + let single_chat = ChatIdBlocked::get_for_contact(context, from_id, Blocked::Request).await?; - chat_id = direct_chat.id; - chat_id_blocked = direct_chat.blocked; + chat_id = single_chat.id; + chat_id_blocked = single_chat.blocked; chat = Chat::load_from_db(context, chat_id).await?; } } @@ -2668,8 +2668,8 @@ async fn lookup_chat_by_reply( return Ok(None); } - // If the parent chat is a 1:1 chat, and the sender added - // a new person to TO/CC, then the message should not go to the 1:1 chat, but to a + // If the parent chat is a single chat, and the sender added + // a new person to TO/CC, then the message should not go to the single chat, but to a // newly created ad-hoc group. let parent_chat = Chat::load_from_db(context, parent_chat_id).await?; if parent_chat.typ == Chattype::Single && mime_parser.recipients.len() > 1 { @@ -2795,7 +2795,7 @@ async fn lookup_or_create_adhoc_group( .map(|(chat_id, blocked)| (chat_id, blocked, true))) } -/// If this method returns true, the message shall be assigned to the 1:1 chat with the sender. +/// If this method returns true, the message shall be assigned to the single chat with the sender. /// If it returns false, it shall be assigned to the parent chat. async fn is_probably_private_reply( context: &Context, @@ -2808,7 +2808,7 @@ async fn is_probably_private_reply( } // Usually we don't want to show private replies in the parent chat, but in the - // 1:1 chat with the sender. + // single chat with the sender. // // There is one exception: Classical MUA replies to two-member groups // should be assigned to the group chat. We restrict this exception to classical emails, as chat-group-messages @@ -2921,7 +2921,7 @@ async fn create_group( // yet unknown group, which was rejected because // Chat-Group-Name, which is in the encrypted part, was // not found. We can't create a properly named group in - // this case, so assign error message to 1:1 chat with the + // this case, so assign error message to a single chat with the // sender instead. Ok(None) } else { @@ -3577,7 +3577,7 @@ async fn create_or_lookup_mailinglist_or_broadcast( name, if chattype == Chattype::InBroadcast { // If we joined the broadcast, we have scanned a QR code. - // Even if 1:1 chat does not exist or is in a contact request, + // Even if a single chat does not exist or is in a contact request, // create the channel as unblocked. Blocked::Not } else { diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 49c82da00a..102c50bad4 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -58,7 +58,7 @@ static MSGRMSG: &[u8] = \n\ hello\n"; -static ONETOONE_NOREPLY_MAIL: &[u8] = +static SINGLE_NOREPLY_MAIL: &[u8] = b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ From: Bob \n\ To: alice@example.org\n\ @@ -90,7 +90,7 @@ async fn test_adhoc_group_is_shown() { let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 1); - receive_imf(&t, ONETOONE_NOREPLY_MAIL, false).await.unwrap(); + receive_imf(&t, SINGLE_NOREPLY_MAIL, false).await.unwrap(); let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 1); @@ -120,7 +120,7 @@ async fn test_adhoc_group_show_accepted_contact_accepted() { assert_eq!(chat::get_chat_msgs(&t, chat_id).await.unwrap().len(), 1); // receive a non-delta-message from Bob, shows up because of the show_emails setting - receive_imf(&t, ONETOONE_NOREPLY_MAIL, false).await.unwrap(); + receive_imf(&t, SINGLE_NOREPLY_MAIL, false).await.unwrap(); assert_eq!(chat::get_chat_msgs(&t, chat_id).await.unwrap().len(), 2); @@ -2157,7 +2157,7 @@ Original signature", ) .await?; let msg = t.get_last_msg().await; - let one2one_chat_id = msg.chat_id; + let single_chat_id = msg.chat_id; let bob = Contact::get_by_id(&t, bob_id).await?; assert_eq!(bob.get_status(), "Original signature"); assert!(!msg.has_html()); @@ -2200,7 +2200,7 @@ Original signature updated", .await?; let bob = Contact::get_by_id(&t, bob_id).await?; assert_eq!(bob.get_status(), "Original signature updated"); - assert_eq!(get_chat_msgs(&t, one2one_chat_id).await?.len(), 2); + assert_eq!(get_chat_msgs(&t, single_chat_id).await?.len(), 2); assert_eq!(get_chat_msgs(&t, ml_chat_id).await?.len(), 1); assert_eq!(Chatlist::try_load(&t, 0, None, None).await?.len(), 2); Ok(()) @@ -3275,7 +3275,7 @@ async fn test_no_private_reply_to_blocked_account() -> Result<()> { /// Regression test for two bugs: /// -/// 1. If you blocked some spammer using DC, the 1:1 messages with that contact +/// 1. If you blocked some spammer using DC, the single chat messages with that contact /// are not received, but they could easily bypass this restriction creating /// a new group with only you two as member. /// 2. A blocked group was sometimes not unblocked when when an unblocked @@ -3706,7 +3706,7 @@ async fn test_mua_user_adds_recipient_to_single_chat() -> Result<()> { let alice = TestContext::new_alice().await; alice.allow_unencrypted().await?; - // Alice sends a 1:1 message to Bob, creating a 1:1 chat. + // Alice sends a message to Bob, creating a single chat. let msg = receive_imf( &alice, b"Subject: =?utf-8?q?Message_from_alice=40example=2Eorg?=\r\n\ @@ -3724,7 +3724,7 @@ async fn test_mua_user_adds_recipient_to_single_chat() -> Result<()> { let single_chat = Chat::load_from_db(&alice, msg.chat_id).await?; assert_eq!(single_chat.typ, Chattype::Single); - // Bob uses a classical MUA to answer in the 1:1 chat. + // Bob uses a classical MUA to answer in the single chat. let msg2 = receive_imf( &alice, b"Subject: Re: Message from alice\r\n\ @@ -3760,10 +3760,7 @@ async fn test_mua_user_adds_recipient_to_single_chat() -> Result<()> { assert_ne!(msg3.chat_id, single_chat.id); let group_chat = Chat::load_from_db(&alice, msg3.chat_id).await?; assert_eq!(group_chat.typ, Chattype::Group); - assert_eq!( - chat::get_chat_contacts(&alice, group_chat.id).await?.len(), - 3 - ); + assert_eq!(get_chat_contacts(&alice, group_chat.id).await?.len(), 3); // Bob uses a classical MUA to answer once more, adding another recipient. // This new recipient should also be added to the group. @@ -3782,15 +3779,12 @@ async fn test_mua_user_adds_recipient_to_single_chat() -> Result<()> { .await? .unwrap(); assert_eq!(msg4.chat_id, group_chat.id); - assert_eq!( - chat::get_chat_contacts(&alice, group_chat.id).await?.len(), - 4 - ); + assert_eq!(get_chat_contacts(&alice, group_chat.id).await?.len(), 4); let fiona_contact_id = Contact::lookup_id_by_addr(&alice, "fiona@example.net", Origin::IncomingTo) .await? .unwrap(); - assert!(chat::is_contact_in_chat(&alice, group_chat.id, fiona_contact_id).await?); + assert!(is_contact_in_chat(&alice, group_chat.id, fiona_contact_id).await?); let fiona_contact = Contact::get_by_id(&alice, fiona_contact_id).await?; assert_eq!(fiona_contact.is_key_contact(), false); @@ -5168,7 +5162,7 @@ async fn test_dont_verify_by_verified_by_unknown() -> Result<()> { } /// Tests that second device assigns outgoing encrypted messages -/// to 1:1 chat with key-contact even if the key of the contact is unknown. +/// to a single chat with key-contact even if the key of the contact is unknown. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_recv_outgoing_msg_before_securejoin() -> Result<()> { let mut tcm = TestContextManager::new(); @@ -5181,7 +5175,7 @@ async fn test_recv_outgoing_msg_before_securejoin() -> Result<()> { let sent_msg = a0.send_text(chat_id_a0_bob, "Hi").await; // Device a1 does not have Bob's key. - // Message is still received in an encrypted 1:1 chat with Bob. + // Message is still received in an encrypted single chat with Bob. // a1 learns the fingerprint of Bob from the Intended Recipient Fingerprint packet, // but not the key. let msg_a1 = a1.recv_msg(&sent_msg).await; @@ -5208,7 +5202,7 @@ async fn test_recv_outgoing_msg_before_securejoin() -> Result<()> { Ok(()) } -/// Tests that outgoing message cannot be assigned to 1:1 chat +/// Tests that outgoing message cannot be assigned to a single chat /// without the intended recipient fingerprint. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_recv_outgoing_msg_no_intended_recipient_fingerprint() -> Result<()> { @@ -5562,7 +5556,7 @@ async fn test_encrypted_adhoc_group_message() -> Result<()> { /// Tests that messages sent to unencrypted group /// with only two members arrive in a group -/// and not in 1:1 chat. +/// and not in a single chat. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_small_unencrypted_group() -> Result<()> { let mut tcm = TestContextManager::new(); diff --git a/src/securejoin.rs b/src/securejoin.rs index 3ab31805db..7ab2a94463 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -657,7 +657,7 @@ pub(crate) async fn handle_securejoin_handshake( return Ok(HandshakeMessage::Ignore); } contact_id.regossip_keys(context).await?; - // for setup-contact, make Alice's one-to-one chat with Bob visible + // for setup-contact, make Alice's single chat with Bob visible // (secure-join-information are shown in the group chat) if grpid.is_empty() { ChatId::create_for_contact(context, contact_id).await?; diff --git a/src/securejoin/bob.rs b/src/securejoin/bob.rs index e4d64556f3..f43c8500dd 100644 --- a/src/securejoin/bob.rs +++ b/src/securejoin/bob.rs @@ -43,10 +43,10 @@ use crate::{chatlist_events, mimefactory}; /// /// # Returns /// -/// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the 1:1 +/// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the single /// chat with Alice, for a SecureJoin QR this is the group chat. pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Result { - // A 1:1 chat is needed to send messages to Alice. When joining a group this chat is + // A single chat is needed to send messages to Alice. When joining a group this chat is // hidden, if a user starts sending messages in it it will be unhidden in // receive_imf. let private_chat_id = private_chat_id(context, &invite).await?; @@ -168,7 +168,7 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul Ok(joining_chat_id) } QrInvite::Contact { .. } => { - // For setup-contact the BobState already ensured the 1:1 chat exists because it is + // For setup-contact the BobState already ensured the single chat exists because it is // used to send the handshake messages. if !key_contains_all_invite_addrs { chat::add_info_msg_with_cmd( @@ -288,7 +288,7 @@ pub(super) async fn handle_auth_required_or_pubkey( QrInvite::Contact { .. } | QrInvite::Broadcast { .. } => {} QrInvite::Group { .. } => { // The message reads "Alice replied, waiting to be added to the group…", - // so only show it when joining a group and not for a 1:1 chat or broadcast channel. + // so only show it when joining a group and not for a single chat or broadcast channel. let contact_id = invite.contact_id(); let msg = stock_str::secure_join_replies(context, contact_id).await; let chat_id = joining_chat_id(context, &invite, chat_id).await?; @@ -430,10 +430,10 @@ impl BobHandshakeMsg { } } -/// Returns the 1:1 chat with the inviter. +/// Returns the single chat with the inviter. /// /// This is the chat in which securejoin messages are sent. -/// The 1:1 chat will be created if it does not yet exist. +/// The single chat will be created if it does not yet exist. async fn private_chat_id(context: &Context, invite: &QrInvite) -> Result { let hidden = match invite { QrInvite::Contact { .. } => Blocked::Not, @@ -451,7 +451,7 @@ async fn private_chat_id(context: &Context, invite: &QrInvite) -> Result /// This is the chat in which you want to notify the user as well. /// /// When joining a group this is the [`ChatId`] of the group chat, when verifying a -/// contact this is the [`ChatId`] of the 1:1 chat. +/// contact this is the [`ChatId`] of the single chat. /// The group chat will be created if it does not yet exist. async fn joining_chat_id( context: &Context, diff --git a/src/securejoin/securejoin_tests.rs b/src/securejoin/securejoin_tests.rs index 8db2c0863e..7434a94df8 100644 --- a/src/securejoin/securejoin_tests.rs +++ b/src/securejoin/securejoin_tests.rs @@ -235,7 +235,7 @@ async fn test_setup_contact_ex(case: SetupContactCase) { assert!(contact_bob.get_name().is_empty()); assert_eq!(contact_bob.is_bot(), false); - // exactly one one-to-one chat should be visible for both now + // exactly one single chat should be visible for both now // (check this before calling alice.get_chat() explicitly below) assert_eq!( Chatlist::try_load(&alice, 0, None, None) @@ -249,7 +249,7 @@ async fn test_setup_contact_ex(case: SetupContactCase) { 1 ); - // Check Alice got the verified message in her 1:1 chat. + // Check Alice got the verified message in her single chat. { let chat = alice.get_chat(&bob).await; let msg = get_chat_msg(&alice, chat.get_id(), 0, 1).await; @@ -620,7 +620,7 @@ async fn test_secure_join_group_ex(v3: bool, remove_invite: bool) -> Result<()> assert_eq!( chat.blocked, Blocked::Yes, - "Alice's 1:1 chat with Bob is not hidden" + "Alice's single chat with Bob is not hidden" ); } @@ -648,7 +648,7 @@ async fn test_secure_join_group_ex(v3: bool, remove_invite: bool) -> Result<()> assert_eq!( chat.blocked, Blocked::Yes, - "Bob's 1:1 chat with Alice is not hidden" + "Bob's single chat with Alice is not hidden" ); for item in chat::get_chat_msgs(&bob.ctx, bob_chatid).await.unwrap() { if let chat::ChatItem::Message { msg_id } = item { @@ -667,12 +667,12 @@ async fn test_secure_join_group_ex(v3: bool, remove_invite: bool) -> Result<()> assert_eq!(chat::get_chat_contacts(&bob, bob_chatid).await?.len(), 2); // On this "happy path", Alice and Bob get only a group-chat where all information are added to. - // The one-to-one chats are used internally for the hidden handshake messages, + // The single chats are used internally for the hidden handshake messages, // however, should not be visible in the UIs. assert_eq!(Chatlist::try_load(&alice, 0, None, None).await?.len(), 1); assert_eq!(Chatlist::try_load(&bob, 0, None, None).await?.len(), 1); - // If Bob then sends a direct message to alice, however, the one-to-one with Alice should appear. + // If Bob then sends a single chat message to alice, however, the single chat with Alice should appear. let bobs_chat_with_alice = bob.create_chat(&alice).await; let sent = bob.send_text(bobs_chat_with_alice.id, "Hello").await; alice.recv_msg(&sent).await; diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index d1f901b5c6..cd5aff0c86 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -433,7 +433,7 @@ fn migrate_key_contacts( Ok(()) }; let old_and_new_members: Vec<(u32, bool, Option)> = match typ { - // 1:1 chats retain: + // Single chats retain: // - address-contact if peerstate is in the "reset" state, // or if there is no key-contact that has the right email address. // - key-contact identified by the Autocrypt key if Autocrypt key does not match the verified key. @@ -444,7 +444,7 @@ fn migrate_key_contacts( let Some((old_member, _)) = old_members.first() else { info!( context, - "1:1 chat {chat_id} doesn't contain contact, probably it's self or device chat." + "Single chat {chat_id} doesn't contain contact, probably it's self or device chat." ); continue; }; @@ -2390,7 +2390,7 @@ UPDATE msgs SET state=24 WHERE state=18; -- Change OutPreparing to OutFailed. sql.execute_migration_transaction( |transaction| { // Newest timestamp of message sent to unencrypted chat with contacts. - // This is for 1:1 chats and ad hoc groups. + // This is for single chats and ad hoc groups. // // Corner case of ad hoc groups with only self as a member is ignored. let max_unencrypted_timestamp: i64 = transaction.query_row( diff --git a/src/stats.rs b/src/stats.rs index 264f449df1..65b4f49815 100644 --- a/src/stats.rs +++ b/src/stats.rs @@ -74,8 +74,8 @@ struct ContactStat { #[serde(skip_serializing_if = "is_false")] bot: bool, - #[serde(skip_serializing_if = "is_false")] - direct_chat: bool, + #[serde(skip_serializing_if = "is_false", rename = "direct_chat")] + single_chat: bool, last_seen: u64, @@ -163,7 +163,7 @@ struct JoinedInvite { /// this tells us whether the contact was verified already. already_verified: bool, /// The type of the invite: - /// "contact" for 1:1 invites that setup a verified contact, + /// "contact" for single chat invites that setup a verified contact, /// "group" for invites that invite to a group, /// "broadcast" for invites that invite to a broadcast channel. /// The invite also performs the contact verification 'along the way'. @@ -473,7 +473,7 @@ async fn get_contact_stats(context: &Context, last_old_contact: u32) -> Result last_old_contact, @@ -516,9 +516,9 @@ async fn get_contact_stats(context: &Context, last_old_contact: u32) -> Result Result Result> { let mut map: BTreeMap = context .sql @@ -650,7 +646,7 @@ async fn update_message_stats_inner(context: &Context, chattype: Chattype) -> Re (), )?; - // This table will hold all 1:1 chats. + // This table will hold all single chats. t.execute( "CREATE TEMP TABLE temp.chat_with_correct_type ( id INTEGER PRIMARY KEY diff --git a/src/test_utils.rs b/src/test_utils.rs index d026325414..f3bb9ef8b3 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -242,7 +242,7 @@ impl TestContextManager { /// Executes SecureJoin protocol between `scanner` and `scanned`. /// - /// Returns chat ID of the 1:1 chat for `scanner`. + /// Returns chat ID of the single chat for `scanner`. pub async fn execute_securejoin(&self, scanner: &TestContext, scanned: &TestContext) -> ChatId { self.section(&format!( "{} scans {}'s QR code", @@ -256,7 +256,7 @@ impl TestContextManager { /// Executes SecureJoin initiated by `joiner` scanning `qr` generated by `inviter`. /// - /// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the 1:1 + /// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the single /// chat with `inviter`, for a SecureJoin QR this is the group chat. pub async fn exec_securejoin_qr( &self, @@ -273,7 +273,7 @@ impl TestContextManager { /// `inviters` devices must have the same primary address. /// All of the `inviters` devices will get the messages and send replies. /// - /// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the 1:1 + /// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the single /// chat with the inviter, for a SecureJoin QR this is the group chat. pub async fn exec_securejoin_qr_multi_device( &self, @@ -951,12 +951,12 @@ ORDER BY id" contact_id } - /// Returns 1:1 [`Chat`] with another account address-contact. + /// Returns a single [`Chat`] with another account address-contact. /// Panics if it doesn't exist. /// May return a blocked chat. /// /// This first creates a contact using the configured details on the other account, then - /// gets the 1:1 chat with this contact. + /// gets the single chat with this contact. pub async fn get_email_chat(&self, other: &TestContext) -> Chat { let contact = self.add_or_lookup_address_contact(other).await; @@ -972,7 +972,7 @@ ORDER BY id" Chat::load_from_db(&self.ctx, chat_id).await.unwrap() } - /// Returns 1:1 [`Chat`] with another account key-contact. + /// Returns a single [`Chat`] with another account key-contact. /// Panics if the chat does not exist. /// /// This first creates a contact, but does not import the key, @@ -993,27 +993,27 @@ ORDER BY id" Chat::load_from_db(&self.ctx, chat_id).await.unwrap() } - /// Creates or returns an existing 1:1 [`ChatId`] with another account. + /// Creates or returns an existing single [`ChatId`] with another account. /// /// This first creates a contact by exporting a vCard from the `other` /// and importing it into `self`, - /// then creates a 1:1 chat with this contact. + /// then creates a single chat with this contact. pub async fn create_chat_id(&self, other: &TestContext) -> ChatId { let contact_id = self.add_or_lookup_contact_id(other).await; ChatId::create_for_contact(self, contact_id).await.unwrap() } - /// Creates or returns an existing 1:1 [`Chat`] with another account. + /// Creates or returns an existing single [`Chat`] with another account. /// /// This first creates a contact by exporting a vCard from the `other` /// and importing it into `self`, - /// then creates a 1:1 chat with this contact. + /// then creates a single chat with this contact. pub async fn create_chat(&self, other: &TestContext) -> Chat { let chat_id = self.create_chat_id(other).await; Chat::load_from_db(self, chat_id).await.unwrap() } - /// Creates or returns an existing 1:1 [`Chat`] with another account + /// Creates or returns an existing single [`Chat`] with another account /// by email address. /// /// This function can be used to create unencrypted chats. @@ -1024,9 +1024,9 @@ ORDER BY id" Chat::load_from_db(self, chat_id).await.unwrap() } - /// Creates or returns an existing [`Contact`] and 1:1 [`Chat`] with another email. + /// Creates or returns an existing [`Contact`] and single [`Chat`] with another email. /// - /// This first creates a contact from the `name` and `addr` and then creates a 1:1 chat + /// This first creates a contact from the `name` and `addr` and then creates a single chat /// with this contact. pub async fn create_chat_with_contact(&self, name: &str, addr: &str) -> Chat { let contact = Contact::create(self, name, addr) diff --git a/src/tests/aeap.rs b/src/tests/aeap.rs index 8d8724dcad..5e61c5c1e3 100644 --- a/src/tests/aeap.rs +++ b/src/tests/aeap.rs @@ -44,7 +44,7 @@ async fn test_change_primary_self_addr() -> Result<()> { } enum ChatForTransition { - OneToOne, + Single, GroupChat, VerifiedGroup, } @@ -52,7 +52,7 @@ use ChatForTransition::*; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_aeap_transition_0() { - check_aeap_transition(OneToOne, false).await; + check_aeap_transition(Single, false).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_aeap_transition_1() { @@ -60,7 +60,7 @@ async fn test_aeap_transition_1() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_aeap_transition_0_verified() { - check_aeap_transition(OneToOne, true).await; + check_aeap_transition(Single, true).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_aeap_transition_1_verified() { @@ -123,7 +123,7 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition, verified: tcm.section("Alice sends another message to Bob, this time from her new addr"); // No matter which chat Alice sends to, the transition should be done in all groups let chat_to_send = match chat_for_transition { - OneToOne => alice.create_chat(bob).await.id, + Single => alice.create_chat(bob).await.id, GroupChat => group1_alice, VerifiedGroup => group3_alice.expect("No verified group"), }; diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index c81b4ff5ff..fae8b3974b 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -22,16 +22,16 @@ use crate::test_utils::{ use crate::tools::SystemTime; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_verified_oneonone_chat_not_broken_by_classical() { - check_verified_oneonone_chat_protection_not_broken(true).await; +async fn test_verified_single_chat_not_broken_by_classical() { + check_verified_single_chat_protection_not_broken(true).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_verified_oneonone_chat_not_broken_by_device_change() { - check_verified_oneonone_chat_protection_not_broken(false).await; +async fn test_verified_single_chat_not_broken_by_device_change() { + check_verified_single_chat_protection_not_broken(false).await; } -async fn check_verified_oneonone_chat_protection_not_broken(by_classical_email: bool) { +async fn check_verified_single_chat_protection_not_broken(by_classical_email: bool) { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; let bob = tcm.bob().await; @@ -83,7 +83,7 @@ async fn check_verified_oneonone_chat_protection_not_broken(by_classical_email: } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_create_verified_oneonone_chat() -> Result<()> { +async fn test_create_verified_single_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; let bob = tcm.bob().await; @@ -168,11 +168,11 @@ async fn test_missing_key_reexecute_securejoin() -> Result<()> { } /// Tests that receiving unencrypted message -/// does not disable protection of 1:1 chat. +/// does not disable protection of single chat. /// /// Instead, an email-chat is created. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_degrade_verified_oneonone_chat() -> Result<()> { +async fn test_degrade_verified_single_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; @@ -755,7 +755,7 @@ async fn test_no_reverification() -> Result<()> { /// so we should mark the contact as verified, /// but with unknown verifier. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_no_direct_verification_via_bcc() -> Result<()> { +async fn test_no_single_verification_via_bcc() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let alice2 = &tcm.alice().await;