From 783c747e99a959d56f14565635c2cae14553973e Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sun, 14 Sep 2025 00:25:49 -0300 Subject: [PATCH 1/2] feat: Synchronize encrypted groups creation across devices (#7001) Unencrypted groups don't have grpid since key-contacts were merged, so we don't sync them for now. --- src/chat.rs | 68 ++++++++++++++++++++++++------------------ src/chat/chat_tests.rs | 55 ++++++++++++++++++++++++++++++++++ src/receive_imf.rs | 9 ++++++ 3 files changed, 103 insertions(+), 29 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 9c2bec1ef6..7d7da8ae7d 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -30,6 +30,7 @@ use crate::debug_logging::maybe_set_logging_xdc; use crate::download::DownloadState; use crate::ephemeral::{Timer as EphemeralTimer, start_chat_ephemeral_timers}; use crate::events::EventType; +use crate::key::self_fingerprint; use crate::location; use crate::log::{LogExt, error, info, warn}; use crate::logged_debug_assert; @@ -2008,17 +2009,21 @@ impl Chat { /// Sends a `SyncAction` synchronising chat contacts to other devices. pub(crate) async fn sync_contacts(&self, context: &Context) -> Result<()> { if self.is_encrypted(context).await? { + let self_fp = self_fingerprint(context).await?; let fingerprint_addrs = context .sql .query_map( - "SELECT c.fingerprint, c.addr + "SELECT c.id, c.fingerprint, c.addr FROM contacts c INNER JOIN chats_contacts cc ON c.id=cc.contact_id WHERE cc.chat_id=? AND cc.add_timestamp >= cc.remove_timestamp", (self.id,), |row| { - let fingerprint = row.get(0)?; - let addr = row.get(1)?; + if row.get::<_, ContactId>(0)? == ContactId::SELF { + return Ok((self_fp.to_string(), String::new())); + } + let fingerprint = row.get(1)?; + let addr = row.get(2)?; Ok((fingerprint, addr)) }, |addrs| addrs.collect::, _>>().map_err(Into::into), @@ -3433,25 +3438,28 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul Ok(list) } -/// Creates a group chat with a given `name`. +/// Creates an encrypted group chat. pub async fn create_group_chat(context: &Context, name: &str) -> Result { - let is_encrypted = true; - create_group_ex(context, is_encrypted, name).await + let encryption = Some(create_id()); + create_group_ex(context, Sync, encryption, name).await } -/// Creates a new unencrypted group chat. +/// Creates an unencrypted group chat. pub async fn create_group_chat_unencrypted(context: &Context, name: &str) -> Result { - let is_encrypted = false; - create_group_ex(context, is_encrypted, name).await + let encryption = None; + create_group_ex(context, Sync, encryption, name).await } /// Creates a group chat. /// -/// * `is_encrypted` - If true, the chat is encrypted (with key-contacts). +/// * `sync` - Whether a multi-device synchronization message should be sent. Ignored for +/// unencrypted chats currently. +/// * `encryption` - If `Some(grpid)`, the chat is encrypted (with key-contacts). /// * `name` - Chat name. pub(crate) async fn create_group_ex( context: &Context, - is_encrypted: bool, + sync: sync::Sync, + encryption: Option, name: &str, ) -> Result { let mut chat_name = sanitize_single_line(name); @@ -3462,12 +3470,7 @@ pub(crate) async fn create_group_ex( chat_name = "…".to_string(); } - let grpid = if is_encrypted { - create_id() - } else { - String::new() - }; - + let grpid = encryption.unwrap_or_default(); let timestamp = create_smeared_timestamp(context); let row_id = context .sql @@ -3475,7 +3478,7 @@ pub(crate) async fn create_group_ex( "INSERT INTO chats (type, name, grpid, param, created_timestamp) VALUES(?, ?, ?, \'U=1\', ?);", - (Chattype::Group, chat_name, grpid, timestamp), + (Chattype::Group, &chat_name, &grpid, timestamp), ) .await?; @@ -3486,7 +3489,7 @@ pub(crate) async fn create_group_ex( chatlist_events::emit_chatlist_changed(context); chatlist_events::emit_chatlist_item_changed(context, chat_id); - if is_encrypted { + if !grpid.is_empty() { // Add "Messages are end-to-end encrypted." message. chat_id.add_encrypted_msg(context, timestamp).await?; } @@ -3497,7 +3500,11 @@ pub(crate) async fn create_group_ex( let text = stock_str::new_group_send_first_message(context).await; add_info_msg(context, chat_id, &text, create_smeared_timestamp(context)).await?; } - + if let (true, true) = (sync.into(), !grpid.is_empty()) { + let id = SyncId::Grpid(grpid); + let action = SyncAction::CreateGroupEncrypted(chat_name); + self::sync(context, id, action).await.log_err(context).ok(); + } Ok(chat_id) } @@ -4706,16 +4713,14 @@ async fn set_contacts_by_fingerprints( "Cannot add key-contacts to unencrypted chat {id}" ); ensure!( - chat.typ == Chattype::OutBroadcast, - "{id} is not a broadcast list", + matches!(chat.typ, Chattype::Group | Chattype::OutBroadcast), + "{id} is not a group or broadcast", ); let mut contacts = HashSet::new(); for (fingerprint, addr) in fingerprint_addrs { - let contact_addr = ContactAddress::new(addr)?; - let contact = - Contact::add_or_lookup_ex(context, "", &contact_addr, fingerprint, Origin::Hidden) - .await? - .0; + let contact = Contact::add_or_lookup_ex(context, "", addr, fingerprint, Origin::Hidden) + .await? + .0; contacts.insert(contact); } let contacts_old = HashSet::::from_iter(get_chat_contacts(context, id).await?); @@ -4754,7 +4759,7 @@ pub(crate) enum SyncId { /// "Message-ID"-s, from oldest to latest. Used for ad-hoc groups. Msgids(Vec), - // Special id for device chat. + /// Special id for device chat. Device, } @@ -4768,6 +4773,8 @@ pub(crate) enum SyncAction { SetMuted(MuteDuration), /// Create broadcast channel with the given name. CreateBroadcast(String), + /// Create encrypted group chat with the given name. + CreateGroupEncrypted(String), Rename(String), /// Set chat contacts by their addresses. SetContacts(Vec), @@ -4833,6 +4840,9 @@ impl Context { if let SyncAction::CreateBroadcast(name) = action { create_broadcast_ex(self, Nosync, grpid.clone(), name.clone()).await?; return Ok(()); + } else if let SyncAction::CreateGroupEncrypted(name) = action { + create_group_ex(self, Nosync, Some(grpid.clone()), name).await?; + return Ok(()); } get_chat_id_by_grpid(self, grpid) .await? @@ -4854,7 +4864,7 @@ impl Context { SyncAction::Accept => chat_id.accept_ex(self, Nosync).await, SyncAction::SetVisibility(v) => chat_id.set_visibility_ex(self, Nosync, *v).await, SyncAction::SetMuted(duration) => set_muted_ex(self, Nosync, chat_id, *duration).await, - SyncAction::CreateBroadcast(_) => { + SyncAction::CreateBroadcast(_) | SyncAction::CreateGroupEncrypted(..) => { Err(anyhow!("sync_alter_chat({id:?}, {action:?}): Bad request.")) } SyncAction::Rename(to) => rename_ex(self, Nosync, chat_id, to).await, diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index c435263147..1c03e31303 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -3836,6 +3836,61 @@ async fn test_sync_name() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_sync_create_group() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice0 = &tcm.alice().await; + let alice1 = &tcm.alice().await; + for a in [alice0, alice1] { + a.set_config_bool(Config::SyncMsgs, true).await?; + } + let bob = &tcm.bob().await; + let a0_bob_contact_id = alice0.add_or_lookup_contact_id(bob).await; + let a1_bob_contact_id = alice1.add_or_lookup_contact_id(bob).await; + let a0_chat_id = create_group_chat(alice0, "grp").await?; + sync(alice0, alice1).await; + let a0_chat = Chat::load_from_db(alice0, a0_chat_id).await?; + let a1_chat_id = get_chat_id_by_grpid(alice1, &a0_chat.grpid) + .await? + .unwrap() + .0; + let a1_chat = Chat::load_from_db(alice1, a1_chat_id).await?; + assert_eq!(a1_chat.get_type(), Chattype::Group); + assert_eq!(a1_chat.is_promoted(), false); + assert_eq!(a1_chat.get_name(), "grp"); + + set_chat_name(alice0, a0_chat_id, "renamed").await?; + sync(alice0, alice1).await; + let a1_chat = Chat::load_from_db(alice1, a1_chat_id).await?; + assert_eq!(a1_chat.is_promoted(), false); + assert_eq!(a1_chat.get_name(), "renamed"); + + add_contact_to_chat(alice0, a0_chat_id, a0_bob_contact_id).await?; + sync(alice0, alice1).await; + let a1_chat = Chat::load_from_db(alice1, a1_chat_id).await?; + assert_eq!(a1_chat.is_promoted(), false); + assert_eq!( + get_chat_contacts(alice1, a1_chat_id).await?, + [a1_bob_contact_id, ContactId::SELF] + ); + + // Let's test a contact removal from another device. + remove_contact_from_chat(alice1, a1_chat_id, a1_bob_contact_id).await?; + sync(alice1, alice0).await; + let a0_chat = Chat::load_from_db(alice0, a0_chat_id).await?; + assert_eq!(a0_chat.is_promoted(), false); + assert_eq!( + get_chat_contacts(alice0, a0_chat_id).await?, + [ContactId::SELF] + ); + + let sent_msg = alice0.send_text(a0_chat_id, "hi").await; + let msg = alice1.recv_msg(&sent_msg).await; + assert_eq!(msg.chat_id, a1_chat_id); + assert_eq!(a1_chat_id.is_promoted(alice1).await?, true); + Ok(()) +} + /// Tests sending JPEG image with .png extension. /// /// This is a regression test, previously sending failed diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 9490e29d50..09d37212f3 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2158,6 +2158,7 @@ RETURNING id if !chat_id.is_trash() && !hidden { let mut chat = Chat::load_from_db(context, chat_id).await?; + let mut update_param = false; // In contrast to most other update-timestamps, // use `sort_timestamp` instead of `sent_timestamp` for the subject-timestamp comparison. @@ -2171,6 +2172,14 @@ RETURNING id let subject = mime_parser.get_subject().unwrap_or_default(); chat.param.set(Param::LastSubject, subject); + update_param = true; + } + + if chat.is_unpromoted() { + chat.param.remove(Param::Unpromoted); + update_param = true; + } + if update_param { chat.update_param(context).await?; } } From be8d47acbc562ef5cf1b1f2bacc16cd2dd8f63a5 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sun, 14 Sep 2025 00:27:05 -0300 Subject: [PATCH 2/2] refactor: Rename chat::create_group_chat() to create_group() If we use modules (which are actually namespaces), we can use shorter names. Another approach is to only use modules for internal code incapsulation and use full names like deltachat-ffi does. --- deltachat-ffi/src/lib.rs | 2 +- deltachat-jsonrpc/src/api.rs | 6 +- deltachat-repl/src/cmdline.rs | 2 +- src/chat.rs | 6 +- src/chat/chat_tests.rs | 96 ++++++++++++++-------------- src/chatlist.rs | 22 +++---- src/constants.rs | 2 +- src/ephemeral/ephemeral_tests.rs | 6 +- src/events/chatlist_events.rs | 29 ++++----- src/mimefactory/mimefactory_tests.rs | 6 +- src/peer_channels.rs | 2 +- src/qr/qr_tests.rs | 8 +-- src/receive_imf/receive_imf_tests.rs | 54 ++++++++-------- src/securejoin/securejoin_tests.rs | 8 +-- src/sync.rs | 2 +- src/test_utils.rs | 5 +- src/tests/aeap.rs | 12 ++-- src/webxdc/maps_integration.rs | 4 +- src/webxdc/webxdc_tests.rs | 56 ++++++++-------- 19 files changed, 162 insertions(+), 166 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 9f85abe44b..c085463682 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -1748,7 +1748,7 @@ pub unsafe extern "C" fn dc_create_group_chat( } let ctx = &*context; - block_on(chat::create_group_chat(ctx, &to_string_lossy(name))) + block_on(chat::create_group(ctx, &to_string_lossy(name))) .context("Failed to create group chat") .log_err(ctx) .map(|id| id.to_u32()) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 4119c96adf..21337a9641 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -969,9 +969,7 @@ impl CommandApi { /// This may be useful if you want to show some help for just created groups. async fn create_group_chat(&self, account_id: u32, name: String) -> Result { let ctx = self.get_context(account_id).await?; - chat::create_group_chat(&ctx, &name) - .await - .map(|id| id.to_u32()) + chat::create_group(&ctx, &name).await.map(|id| id.to_u32()) } /// Create a new unencrypted group chat. @@ -980,7 +978,7 @@ impl CommandApi { /// address-contacts. async fn create_group_chat_unencrypted(&self, account_id: u32, name: String) -> Result { let ctx = self.get_context(account_id).await?; - chat::create_group_chat_unencrypted(&ctx, &name) + chat::create_group_unencrypted(&ctx, &name) .await .map(|id| id.to_u32()) } diff --git a/deltachat-repl/src/cmdline.rs b/deltachat-repl/src/cmdline.rs index c94b706152..7119f455b1 100644 --- a/deltachat-repl/src/cmdline.rs +++ b/deltachat-repl/src/cmdline.rs @@ -737,7 +737,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu } "creategroup" => { ensure!(!arg1.is_empty(), "Argument missing."); - let chat_id = chat::create_group_chat(&context, arg1).await?; + let chat_id = chat::create_group(&context, arg1).await?; println!("Group#{chat_id} created successfully."); } diff --git a/src/chat.rs b/src/chat.rs index 7d7da8ae7d..f9612f4db0 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3439,13 +3439,13 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul } /// Creates an encrypted group chat. -pub async fn create_group_chat(context: &Context, name: &str) -> Result { +pub async fn create_group(context: &Context, name: &str) -> Result { let encryption = Some(create_id()); create_group_ex(context, Sync, encryption, name).await } /// Creates an unencrypted group chat. -pub async fn create_group_chat_unencrypted(context: &Context, name: &str) -> Result { +pub async fn create_group_unencrypted(context: &Context, name: &str) -> Result { let encryption = None; create_group_ex(context, Sync, encryption, name).await } @@ -3520,7 +3520,7 @@ pub(crate) async fn create_group_ex( /// which would make it hard to grep for it. /// /// After creation, the chat contains no recipients and is in _unpromoted_ state; -/// see [`create_group_chat`] for more information on the unpromoted state. +/// see [`create_group`] for more information on the unpromoted state. /// /// Returns the created chat's id. pub async fn create_broadcast(context: &Context, chat_name: String) -> Result { diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 1c03e31303..d6b96ae88a 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -96,7 +96,7 @@ async fn test_get_draft() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_delete_draft() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "abc").await?; + let chat_id = create_group(&t, "abc").await?; let mut msg = Message::new_text("hi!".to_string()); chat_id.set_draft(&t, Some(&mut msg)).await?; @@ -120,7 +120,7 @@ async fn test_forwarding_draft_failing() -> Result<()> { chat_id.set_draft(&t, Some(&mut msg)).await?; assert_eq!(msg.id, chat_id.get_draft(&t).await?.unwrap().id); - let chat_id2 = create_group_chat(&t, "foo").await?; + let chat_id2 = create_group(&t, "foo").await?; assert!(forward_msgs(&t, &[msg.id], chat_id2).await.is_err()); Ok(()) } @@ -169,7 +169,7 @@ async fn test_draft_stable_ids() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_only_one_draft_per_chat() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "abc").await?; + let chat_id = create_group(&t, "abc").await?; let msgs: Vec = (1..=1000) .map(|i| Message::new_text(i.to_string())) @@ -196,7 +196,7 @@ async fn test_only_one_draft_per_chat() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_change_quotes_on_reused_message_object() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "chat").await?; + let chat_id = create_group(&t, "chat").await?; let quote1 = Message::load_from_db(&t, send_text_msg(&t, chat_id, "quote1".to_string()).await?).await?; let quote2 = @@ -247,7 +247,7 @@ async fn test_quote_replies() -> Result<()> { let alice = TestContext::new_alice().await; let bob = TestContext::new_bob().await; - let grp_chat_id = create_group_chat(&alice, "grp").await?; + let grp_chat_id = create_group(&alice, "grp").await?; 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?; @@ -295,7 +295,7 @@ async fn test_quote_replies() -> Result<()> { async fn test_add_contact_to_chat_ex_add_self() { // Adding self to a contact should succeed, even though it's pointless. let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await.unwrap(); + let chat_id = create_group(&t, "foo").await.unwrap(); let added = add_contact_to_chat_ex(&t, Nosync, chat_id, ContactId::SELF, false) .await .unwrap(); @@ -334,7 +334,7 @@ async fn test_member_add_remove() -> Result<()> { } tcm.section("Create and promote a group."); - let alice_chat_id = create_group_chat(&alice, "Group chat").await?; + let alice_chat_id = create_group(&alice, "Group chat").await?; let alice_fiona_contact_id = alice.add_or_lookup_contact_id(&fiona).await; add_contact_to_chat(&alice, alice_chat_id, alice_fiona_contact_id).await?; let sent = alice @@ -396,7 +396,7 @@ async fn test_parallel_member_remove() -> Result<()> { let alice_charlie_contact_id = alice.add_or_lookup_contact_id(&charlie).await; tcm.section("Alice creates and promotes a group"); - let alice_chat_id = create_group_chat(&alice, "Group chat").await?; + let alice_chat_id = create_group(&alice, "Group chat").await?; add_contact_to_chat(&alice, alice_chat_id, alice_bob_contact_id).await?; add_contact_to_chat(&alice, alice_chat_id, alice_fiona_contact_id).await?; let alice_sent_msg = alice @@ -453,7 +453,7 @@ async fn test_msg_with_implicit_member_removed() -> Result<()> { let alice_bob_contact_id = alice.add_or_lookup_contact_id(&bob).await; let alice_fiona_contact_id = alice.add_or_lookup_contact_id(&fiona).await; let bob_fiona_contact_id = bob.add_or_lookup_contact_id(&fiona).await; - let alice_chat_id = create_group_chat(&alice, "Group chat").await?; + let alice_chat_id = create_group(&alice, "Group chat").await?; add_contact_to_chat(&alice, alice_chat_id, alice_bob_contact_id).await?; let sent_msg = alice.send_text(alice_chat_id, "I created a group").await; let bob_received_msg = bob.recv_msg(&sent_msg).await; @@ -499,7 +499,7 @@ async fn test_modify_chat_multi_device() -> Result<()> { a1.set_config_bool(Config::BccSelf, true).await?; // create group and sync it to the second device - let a1_chat_id = create_group_chat(&a1, "foo").await?; + let a1_chat_id = create_group(&a1, "foo").await?; let sent = a1.send_text(a1_chat_id, "ho!").await; let a1_msg = a1.get_last_msg().await; let a1_chat = Chat::load_from_db(&a1, a1_chat_id).await?; @@ -597,7 +597,7 @@ async fn test_modify_chat_disordered() -> Result<()> { let fiona = tcm.fiona().await; let fiona_id = alice.add_or_lookup_contact_id(&fiona).await; - let alice_chat_id = create_group_chat(&alice, "foo").await?; + let alice_chat_id = create_group(&alice, "foo").await?; send_text_msg(&alice, alice_chat_id, "populate".to_string()).await?; add_contact_to_chat(&alice, alice_chat_id, bob_id).await?; @@ -674,7 +674,7 @@ async fn test_modify_chat_lost() -> Result<()> { let fiona = tcm.fiona().await; let fiona_id = alice.add_or_lookup_contact_id(&fiona).await; - let alice_chat_id = create_group_chat(&alice, "foo").await?; + let alice_chat_id = create_group(&alice, "foo").await?; add_contact_to_chat(&alice, alice_chat_id, bob_id).await?; add_contact_to_chat(&alice, alice_chat_id, charlie_id).await?; add_contact_to_chat(&alice, alice_chat_id, fiona_id).await?; @@ -715,7 +715,7 @@ async fn test_leave_group() -> Result<()> { let bob = tcm.bob().await; tcm.section("Alice creates group chat with Bob."); - let alice_chat_id = create_group_chat(&alice, "foo").await?; + let alice_chat_id = create_group(&alice, "foo").await?; let bob_contact = alice.add_or_lookup_contact(&bob).await.id; add_contact_to_chat(&alice, alice_chat_id, bob_contact).await?; @@ -1374,7 +1374,7 @@ async fn test_pinned() { tokio::time::sleep(std::time::Duration::from_millis(1000)).await; let chat_id2 = t.get_self_chat().await.id; tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - let chat_id3 = create_group_chat(&t, "foo").await.unwrap(); + let chat_id3 = create_group(&t, "foo").await.unwrap(); let chatlist = get_chats_from_chat_list(&t, DC_GCL_NO_SPECIALS).await; assert_eq!(chatlist, vec![chat_id3, chat_id2, chat_id1]); @@ -1464,7 +1464,7 @@ async fn test_set_chat_name() { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; - let chat_id = create_group_chat(alice, "foo").await.unwrap(); + let chat_id = create_group(alice, "foo").await.unwrap(); assert_eq!( Chat::load_from_db(alice, chat_id).await.unwrap().get_name(), "foo" @@ -1536,7 +1536,7 @@ async fn test_shall_attach_selfavatar() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let chat_id = create_group_chat(alice, "foo").await?; + let chat_id = create_group(alice, "foo").await?; assert!(!shall_attach_selfavatar(alice, chat_id).await?); let contact_id = alice.add_or_lookup_contact_id(bob).await; @@ -1558,7 +1558,7 @@ async fn test_profile_data_on_group_leave() -> Result<()> { let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; let bob = &tcm.bob().await; - let chat_id = create_group_chat(t, "foo").await?; + let chat_id = create_group(t, "foo").await?; let contact_id = t.add_or_lookup_contact_id(bob).await; add_contact_to_chat(t, chat_id, contact_id).await?; @@ -1583,7 +1583,7 @@ async fn test_profile_data_on_group_leave() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_set_mute_duration() { let t = TestContext::new().await; - let chat_id = create_group_chat(&t, "foo").await.unwrap(); + let chat_id = create_group(&t, "foo").await.unwrap(); // Initial assert_eq!( Chat::load_from_db(&t, chat_id).await.unwrap().is_muted(), @@ -1632,7 +1632,7 @@ async fn test_set_mute_duration() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_add_info_msg() -> Result<()> { let t = TestContext::new().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; add_info_msg(&t, chat_id, "foo info", time()).await?; let msg = t.get_last_msg_in(chat_id).await; @@ -1649,7 +1649,7 @@ async fn test_add_info_msg() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_add_info_msg_with_cmd() -> Result<()> { let t = TestContext::new().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let msg_id = add_info_msg_with_cmd( &t, chat_id, @@ -1918,14 +1918,14 @@ async fn test_classic_email_chat() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_chat_get_color() -> Result<()> { let t = TestContext::new().await; - let chat_id = create_group_chat_unencrypted(&t, "a chat").await?; + let chat_id = create_group_unencrypted(&t, "a chat").await?; let color1 = Chat::load_from_db(&t, chat_id).await?.get_color(&t).await?; assert_eq!(color1, 0x613dd7); // upper-/lowercase makes a difference for the colors, these are different groups // (in contrast to email addresses, where upper-/lowercase is ignored in practise) let t = TestContext::new().await; - let chat_id = create_group_chat_unencrypted(&t, "A CHAT").await?; + let chat_id = create_group_unencrypted(&t, "A CHAT").await?; let color2 = Chat::load_from_db(&t, chat_id).await?.get_color(&t).await?; assert_ne!(color2, color1); Ok(()) @@ -1935,7 +1935,7 @@ async fn test_chat_get_color() -> Result<()> { async fn test_chat_get_color_encrypted() -> Result<()> { let mut tcm = TestContextManager::new(); let t = &tcm.alice().await; - let chat_id = create_group_chat(t, "a chat").await?; + let chat_id = create_group(t, "a chat").await?; let color1 = Chat::load_from_db(t, chat_id).await?.get_color(t).await?; set_chat_name(t, chat_id, "A CHAT").await?; let color2 = Chat::load_from_db(t, chat_id).await?.get_color(t).await?; @@ -2124,7 +2124,7 @@ async fn test_forward_info_msg() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let chat_id1 = create_group_chat(alice, "a").await?; + let chat_id1 = create_group(alice, "a").await?; send_text_msg(alice, chat_id1, "msg one".to_string()).await?; let bob_id = alice.add_or_lookup_contact_id(bob).await; add_contact_to_chat(alice, chat_id1, bob_id).await?; @@ -2191,7 +2191,7 @@ async fn test_forward_group() -> Result<()> { let bob_chat = bob.create_chat(&alice).await; // Alice creates a group with Bob. - let alice_group_chat_id = create_group_chat(&alice, "Group").await?; + let alice_group_chat_id = create_group(&alice, "Group").await?; let bob_id = alice.add_or_lookup_contact_id(&bob).await; let charlie_id = alice.add_or_lookup_contact_id(&charlie).await; add_contact_to_chat(&alice, alice_group_chat_id, bob_id).await?; @@ -2243,7 +2243,7 @@ async fn test_only_minimal_data_are_forwarded() -> Result<()> { .set_config(Config::Displayname, Some("secretname")) .await?; let bob_id = alice.add_or_lookup_contact_id(&bob).await; - let group_id = create_group_chat(&alice, "secretgrpname").await?; + let group_id = create_group(&alice, "secretgrpname").await?; add_contact_to_chat(&alice, group_id, bob_id).await?; let mut msg = Message::new_text("bla foo".to_owned()); let sent_msg = alice.send_msg(group_id, &mut msg).await; @@ -2258,7 +2258,7 @@ async fn test_only_minimal_data_are_forwarded() -> Result<()> { let orig_msg = bob.recv_msg(&sent_msg).await; let charlie_id = bob.add_or_lookup_contact_id(&charlie).await; let single_id = ChatId::create_for_contact(&bob, charlie_id).await?; - let group_id = create_group_chat(&bob, "group2").await?; + let group_id = create_group(&bob, "group2").await?; add_contact_to_chat(&bob, group_id, charlie_id).await?; let broadcast_id = create_broadcast(&bob, "Channel".to_string()).await?; add_contact_to_chat(&bob, broadcast_id, charlie_id).await?; @@ -2356,7 +2356,7 @@ async fn test_save_msgs_order() -> Result<()> { for a in [alice, alice1] { a.set_config_bool(Config::SyncMsgs, true).await?; } - let chat_id = create_group_chat(alice, "grp").await?; + let chat_id = create_group(alice, "grp").await?; let sent = [ alice.send_text(chat_id, "0").await, alice.send_text(chat_id, "1").await, @@ -2477,7 +2477,7 @@ async fn test_resend_own_message() -> Result<()> { let alice = TestContext::new_alice().await; let bob = TestContext::new_bob().await; let fiona = TestContext::new_fiona().await; - let alice_grp = create_group_chat(&alice, "grp").await?; + let alice_grp = create_group(&alice, "grp").await?; add_contact_to_chat( &alice, alice_grp, @@ -2564,7 +2564,7 @@ async fn test_resend_foreign_message_fails() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_grp = create_group_chat(alice, "grp").await?; + let alice_grp = create_group(alice, "grp").await?; add_contact_to_chat(alice, alice_grp, alice.add_or_lookup_contact_id(bob).await).await?; let sent1 = alice.send_text(alice_grp, "alice->bob").await; @@ -2581,7 +2581,7 @@ async fn test_resend_info_message_fails() -> Result<()> { let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; - let alice_grp = create_group_chat(alice, "grp").await?; + let alice_grp = create_group(alice, "grp").await?; add_contact_to_chat(alice, alice_grp, alice.add_or_lookup_contact_id(bob).await).await?; alice.send_text(alice_grp, "alice->bob").await; @@ -2604,7 +2604,7 @@ async fn test_can_send_group() -> Result<()> { let chat_id = ChatId::create_for_contact(&alice, bob).await?; let chat = Chat::load_from_db(&alice, chat_id).await?; assert!(chat.can_send(&alice).await?); - let chat_id = create_group_chat(&alice, "foo").await?; + let chat_id = create_group(&alice, "foo").await?; assert_eq!( Chat::load_from_db(&alice, chat_id) .await? @@ -3103,7 +3103,7 @@ async fn test_chat_get_encryption_info() -> Result<()> { let contact_bob = alice.add_or_lookup_contact_id(bob).await; let contact_fiona = alice.add_or_lookup_contact_id(fiona).await; - let chat_id = create_group_chat(alice, "Group").await?; + let chat_id = create_group(alice, "Group").await?; assert_eq!( chat_id.get_encryption_info(alice).await?, "End-to-end encryption available" @@ -3183,8 +3183,8 @@ async fn test_out_failed_on_all_keys_missing() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_chat_media() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id1 = create_group_chat(&t, "foo").await?; - let chat_id2 = create_group_chat(&t, "bar").await?; + let chat_id1 = create_group(&t, "foo").await?; + let chat_id2 = create_group(&t, "bar").await?; assert_eq!( get_chat_media( @@ -3408,7 +3408,7 @@ async fn test_get_chat_media_webxdc_order() -> Result<()> { async fn test_blob_renaming() -> Result<()> { let alice = TestContext::new_alice().await; let bob = TestContext::new_bob().await; - let chat_id = create_group_chat(&alice, "Group").await?; + let chat_id = create_group(&alice, "Group").await?; add_contact_to_chat(&alice, chat_id, alice.add_or_lookup_contact_id(&bob).await).await?; let file = alice.get_blobdir().join("harmless_file.\u{202e}txt.exe"); fs::write(&file, "aaa").await?; @@ -3847,7 +3847,7 @@ async fn test_sync_create_group() -> Result<()> { let bob = &tcm.bob().await; let a0_bob_contact_id = alice0.add_or_lookup_contact_id(bob).await; let a1_bob_contact_id = alice1.add_or_lookup_contact_id(bob).await; - let a0_chat_id = create_group_chat(alice0, "grp").await?; + let a0_chat_id = create_group(alice0, "grp").await?; sync(alice0, alice1).await; let a0_chat = Chat::load_from_db(alice0, a0_chat_id).await?; let a1_chat_id = get_chat_id_by_grpid(alice1, &a0_chat.grpid) @@ -4120,7 +4120,7 @@ async fn test_add_member_bug() -> Result<()> { let alice_fiona_contact_id = alice.add_or_lookup_contact_id(fiona).await; // Create a group. - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; add_contact_to_chat(alice, alice_chat_id, alice_fiona_contact_id).await?; @@ -4164,7 +4164,7 @@ async fn test_past_members() -> Result<()> { let alice_fiona_contact_id = alice.add_or_lookup_contact_id(fiona).await; tcm.section("Alice creates a chat."); - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_fiona_contact_id).await?; alice .send_text(alice_chat_id, "Hi! I created a group.") @@ -4198,7 +4198,7 @@ async fn non_member_cannot_modify_member_list() -> Result<()> { let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await; - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; let alice_sent_msg = alice .send_text(alice_chat_id, "Hi! I created a group.") @@ -4235,7 +4235,7 @@ async fn unpromoted_group_no_tombstones() -> Result<()> { let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await; let alice_fiona_contact_id = alice.add_or_lookup_contact_id(fiona).await; - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; add_contact_to_chat(alice, alice_chat_id, alice_fiona_contact_id).await?; assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 3); @@ -4266,7 +4266,7 @@ async fn test_expire_past_members_after_60_days() -> Result<()> { let fiona = &tcm.fiona().await; let alice_fiona_contact_id = alice.add_or_lookup_contact_id(fiona).await; - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_fiona_contact_id).await?; alice .send_text(alice_chat_id, "Hi! I created a group.") @@ -4303,7 +4303,7 @@ async fn test_past_members_order() -> Result<()> { let fiona = tcm.fiona().await; let fiona_contact_id = t.add_or_lookup_contact_id(&fiona).await; - let chat_id = create_group_chat(t, "Group chat").await?; + let chat_id = create_group(t, "Group chat").await?; add_contact_to_chat(t, chat_id, bob_contact_id).await?; add_contact_to_chat(t, chat_id, charlie_contact_id).await?; add_contact_to_chat(t, chat_id, fiona_contact_id).await?; @@ -4365,7 +4365,7 @@ async fn test_restore_backup_after_60_days() -> Result<()> { let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await; let alice_charlie_contact_id = alice.add_or_lookup_contact_id(charlie).await; - let alice_chat_id = create_group_chat(alice, "Group chat").await?; + let alice_chat_id = create_group(alice, "Group chat").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; add_contact_to_chat(alice, alice_chat_id, alice_charlie_contact_id).await?; @@ -4735,7 +4735,7 @@ async fn test_no_address_contacts_in_group_chats() -> Result<()> { let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; - let chat_id = create_group_chat(alice, "Group chat").await?; + let chat_id = create_group(alice, "Group chat").await?; let bob_key_contact_id = alice.add_or_lookup_contact_id(bob).await; let charlie_address_contact_id = alice.add_or_lookup_address_contact_id(charlie).await; @@ -4794,7 +4794,7 @@ async fn test_create_unencrypted_group_chat() -> Result<()> { let bob = &tcm.bob().await; let charlie = &tcm.charlie().await; - let chat_id = create_group_chat_unencrypted(alice, "Group chat").await?; + let chat_id = create_group_unencrypted(alice, "Group chat").await?; let bob_key_contact_id = alice.add_or_lookup_contact_id(bob).await; let charlie_address_contact_id = alice.add_or_lookup_address_contact_id(charlie).await; @@ -4815,7 +4815,7 @@ async fn test_create_unencrypted_group_chat() -> Result<()> { async fn test_create_group_invalid_name() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; - let chat_id = create_group_chat(alice, " ").await?; + let chat_id = create_group(alice, " ").await?; let chat = Chat::load_from_db(alice, chat_id).await?; assert_eq!(chat.get_name(), "…"); Ok(()) @@ -4861,7 +4861,7 @@ async fn test_long_group_name() -> Result<()> { let bob = &tcm.bob().await; let group_name = "δδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδ"; - let alice_chat_id = create_group_chat(alice, group_name).await?; + let alice_chat_id = create_group(alice, group_name).await?; let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; let sent = alice diff --git a/src/chatlist.rs b/src/chatlist.rs index 1616ebe774..81734a869f 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -481,7 +481,7 @@ mod tests { use super::*; use crate::chat::save_msgs; use crate::chat::{ - add_contact_to_chat, create_group_chat, get_chat_contacts, remove_contact_from_chat, + add_contact_to_chat, create_group, get_chat_contacts, remove_contact_from_chat, send_text_msg, }; use crate::receive_imf::receive_imf; @@ -495,9 +495,9 @@ mod tests { async fn test_try_load() { let mut tcm = TestContextManager::new(); let bob = &tcm.bob().await; - let chat_id1 = create_group_chat(bob, "a chat").await.unwrap(); - let chat_id2 = create_group_chat(bob, "b chat").await.unwrap(); - let chat_id3 = create_group_chat(bob, "c chat").await.unwrap(); + let chat_id1 = create_group(bob, "a chat").await.unwrap(); + let chat_id2 = create_group(bob, "b chat").await.unwrap(); + let chat_id3 = create_group(bob, "c chat").await.unwrap(); // check that the chatlist starts with the most recent message let chats = Chatlist::try_load(bob, 0, None, None).await.unwrap(); @@ -530,7 +530,7 @@ mod tests { // receive a message from alice let alice = &tcm.alice().await; - let alice_chat_id = create_group_chat(alice, "alice chat").await.unwrap(); + let alice_chat_id = create_group(alice, "alice chat").await.unwrap(); add_contact_to_chat( alice, alice_chat_id, @@ -568,7 +568,7 @@ mod tests { async fn test_sort_self_talk_up_on_forward() { let t = TestContext::new_alice().await; t.update_device_chats().await.unwrap(); - create_group_chat(&t, "a chat").await.unwrap(); + create_group(&t, "a chat").await.unwrap(); let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 3); @@ -755,7 +755,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_summary_unwrap() { let t = TestContext::new().await; - let chat_id1 = create_group_chat(&t, "a chat").await.unwrap(); + let chat_id1 = create_group(&t, "a chat").await.unwrap(); let mut msg = Message::new_text("foo:\nbar \r\n test".to_string()); chat_id1.set_draft(&t, Some(&mut msg)).await.unwrap(); @@ -771,7 +771,7 @@ mod tests { async fn test_get_summary_deleted_draft() { let t = TestContext::new().await; - let chat_id = create_group_chat(&t, "a chat").await.unwrap(); + let chat_id = create_group(&t, "a chat").await.unwrap(); let mut msg = Message::new_text("Foobar".to_string()); chat_id.set_draft(&t, Some(&mut msg)).await.unwrap(); @@ -810,9 +810,9 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_load_broken() { let t = TestContext::new_bob().await; - let chat_id1 = create_group_chat(&t, "a chat").await.unwrap(); - create_group_chat(&t, "b chat").await.unwrap(); - create_group_chat(&t, "c chat").await.unwrap(); + let chat_id1 = create_group(&t, "a chat").await.unwrap(); + create_group(&t, "b chat").await.unwrap(); + create_group(&t, "c chat").await.unwrap(); // check that the chatlist starts with the most recent message let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); diff --git a/src/constants.rs b/src/constants.rs index 5a615ace18..2760cab4b8 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -134,7 +134,7 @@ pub enum Chattype { /// Group chat. /// - /// Created by [`crate::chat::create_group_chat`]. + /// Created by [`crate::chat::create_group`]. Group = 120, /// An (unencrypted) mailing list, diff --git a/src/ephemeral/ephemeral_tests.rs b/src/ephemeral/ephemeral_tests.rs index 6c140b4f33..0cbb77df6a 100644 --- a/src/ephemeral/ephemeral_tests.rs +++ b/src/ephemeral/ephemeral_tests.rs @@ -12,7 +12,7 @@ use crate::receive_imf::receive_imf; use crate::test_utils::{TestContext, TestContextManager}; use crate::timesmearing::MAX_SECONDS_TO_LEND_FROM_FUTURE; use crate::{ - chat::{self, Chat, ChatItem, create_group_chat, send_text_msg}, + chat::{self, Chat, ChatItem, create_group, send_text_msg}, tools::IsNoneOrEmpty, }; @@ -164,7 +164,7 @@ async fn test_ephemeral_enable_disable() -> Result<()> { async fn test_ephemeral_unpromoted() -> Result<()> { let alice = TestContext::new_alice().await; - let chat_id = create_group_chat(&alice, "Group name").await?; + let chat_id = create_group(&alice, "Group name").await?; // Group is unpromoted, the timer can be changed without sending a message. assert!(chat_id.is_unpromoted(&alice).await?); @@ -799,7 +799,7 @@ async fn test_ephemeral_timer_non_member() -> Result<()> { let bob = &tcm.bob().await; let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await; - let alice_chat_id = create_group_chat(alice, "Group name").await?; + let alice_chat_id = create_group(alice, "Group name").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?; send_text_msg(alice, alice_chat_id, "Hi!".to_string()).await?; diff --git a/src/events/chatlist_events.rs b/src/events/chatlist_events.rs index 15c9f75af4..93ea7b6803 100644 --- a/src/events/chatlist_events.rs +++ b/src/events/chatlist_events.rs @@ -66,8 +66,7 @@ mod test_chatlist_events { use crate::{ EventType, chat::{ - self, ChatId, ChatVisibility, MuteDuration, create_broadcast, create_group_chat, - set_muted, + self, ChatId, ChatVisibility, MuteDuration, create_broadcast, create_group, set_muted, }, config::Config, constants::*, @@ -138,7 +137,7 @@ mod test_chatlist_events { async fn test_change_chat_visibility() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat_id = create_group_chat(&alice, "my_group").await?; + let chat_id = create_group(&alice, "my_group").await?; chat_id .set_visibility(&alice, ChatVisibility::Pinned) @@ -284,7 +283,7 @@ mod test_chatlist_events { async fn test_delete_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; alice.evtracker.clear_events(); chat.delete(&alice).await?; @@ -294,11 +293,11 @@ mod test_chatlist_events { /// Create group chat #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_create_group_chat() -> Result<()> { + async fn test_create_group() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; alice.evtracker.clear_events(); - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; wait_for_chatlist_and_specific_item(&alice, chat).await; Ok(()) } @@ -319,7 +318,7 @@ mod test_chatlist_events { async fn test_mute_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; alice.evtracker.clear_events(); chat::set_muted(&alice, chat, MuteDuration::Forever).await?; @@ -338,7 +337,7 @@ mod test_chatlist_events { async fn test_mute_chat_expired() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; let mute_duration = MuteDuration::Until( std::time::SystemTime::now() @@ -358,7 +357,7 @@ mod test_chatlist_events { async fn test_change_chat_name() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; alice.evtracker.clear_events(); chat::set_chat_name(&alice, chat, "New Name").await?; @@ -372,7 +371,7 @@ mod test_chatlist_events { async fn test_change_chat_profile_image() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; alice.evtracker.clear_events(); let file = alice.dir.path().join("avatar.png"); @@ -445,7 +444,7 @@ mod test_chatlist_events { async fn test_delete_message() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; let message = chat::send_text_msg(&alice, chat, "Hello World".to_owned()).await?; alice.evtracker.clear_events(); @@ -503,7 +502,7 @@ mod test_chatlist_events { async fn test_update_after_ephemeral_messages() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; chat.set_ephemeral_timer(&alice, crate::ephemeral::Timer::Enabled { duration: 60 }) .await?; alice @@ -547,7 +546,7 @@ First thread."#; let alice = tcm.alice().await; let bob = tcm.bob().await; - let alice_chatid = chat::create_group_chat(&alice.ctx, "the chat").await?; + let alice_chatid = chat::create_group(&alice.ctx, "the chat").await?; // Step 1: Generate QR-code, secure-join implied by chatid let qr = get_securejoin_qr(&alice.ctx, Some(alice_chatid)).await?; @@ -594,7 +593,7 @@ First thread."#; async fn test_resend_message() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; let msg_id = chat::send_text_msg(&alice, chat, "Hello".to_owned()).await?; let _ = alice.pop_sent_msg().await; @@ -614,7 +613,7 @@ First thread."#; async fn test_reaction() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = tcm.alice().await; - let chat = create_group_chat(&alice, "My Group").await?; + let chat = create_group(&alice, "My Group").await?; let msg_id = chat::send_text_msg(&alice, chat, "Hello".to_owned()).await?; let _ = alice.pop_sent_msg().await; diff --git a/src/mimefactory/mimefactory_tests.rs b/src/mimefactory/mimefactory_tests.rs index a058c778f4..b4aee315b5 100644 --- a/src/mimefactory/mimefactory_tests.rs +++ b/src/mimefactory/mimefactory_tests.rs @@ -6,7 +6,7 @@ use std::time::Duration; use super::*; use crate::chat::{ - self, ChatId, add_contact_to_chat, create_group_chat, remove_contact_from_chat, send_text_msg, + self, ChatId, add_contact_to_chat, create_group, remove_contact_from_chat, send_text_msg, }; use crate::chatlist::Chatlist; use crate::constants; @@ -351,7 +351,7 @@ async fn test_subject_in_group() -> Result<()> { let mut tcm = TestContextManager::new(); let t = tcm.alice().await; let bob = tcm.bob().await; - let group_id = chat::create_group_chat(&t, "groupname").await.unwrap(); + let group_id = chat::create_group(&t, "groupname").await.unwrap(); let bob_contact_id = t.add_or_lookup_contact_id(&bob).await; chat::add_contact_to_chat(&t, group_id, bob_contact_id).await?; @@ -753,7 +753,7 @@ async fn test_remove_member_bcc() -> Result<()> { let charlie_contact = Contact::get_by_id(alice, charlie_id).await?; let charlie_addr = charlie_contact.get_addr(); - let alice_chat_id = create_group_chat(alice, "foo").await?; + let alice_chat_id = create_group(alice, "foo").await?; add_contact_to_chat(alice, alice_chat_id, bob_id).await?; add_contact_to_chat(alice, alice_chat_id, charlie_id).await?; send_text_msg(alice, alice_chat_id, "Creating a group".to_string()).await?; diff --git a/src/peer_channels.rs b/src/peer_channels.rs index ad78d99250..cf7c1918a1 100644 --- a/src/peer_channels.rs +++ b/src/peer_channels.rs @@ -948,7 +948,7 @@ mod tests { let mut tcm = TestContextManager::new(); let alice = &mut tcm.alice().await; let bob = &mut tcm.bob().await; - let group = chat::create_group_chat(alice, "group chat").await.unwrap(); + let group = chat::create_group(alice, "group chat").await.unwrap(); // Alice sends webxdc to bob let mut instance = Message::new(Viewtype::File); diff --git a/src/qr/qr_tests.rs b/src/qr/qr_tests.rs index b4e459800d..e7e2cbf320 100644 --- a/src/qr/qr_tests.rs +++ b/src/qr/qr_tests.rs @@ -1,5 +1,5 @@ use super::*; -use crate::chat::create_group_chat; +use crate::chat::create_group; use crate::config::Config; use crate::securejoin::get_securejoin_qr; use crate::test_utils::{TestContext, TestContextManager, sync}; @@ -479,7 +479,7 @@ async fn test_withdraw_verifycontact() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_withdraw_verifygroup() -> Result<()> { let alice = TestContext::new_alice().await; - let chat_id = create_group_chat(&alice, "foo").await?; + let chat_id = create_group(&alice, "foo").await?; let qr = get_securejoin_qr(&alice, Some(chat_id)).await?; // scanning own verify-group code offers withdrawing @@ -520,8 +520,8 @@ async fn test_withdraw_multidevice() -> Result<()> { // Alice creates two QR codes on the first device: // group QR code and contact QR code. - let chat_id = create_group_chat(alice, "Group").await?; - let chat2_id = create_group_chat(alice, "Group 2").await?; + let chat_id = create_group(alice, "Group").await?; + let chat2_id = create_group(alice, "Group 2").await?; let contact_qr = get_securejoin_qr(alice, None).await?; let group_qr = get_securejoin_qr(alice, Some(chat_id)).await?; let group2_qr = get_securejoin_qr(alice, Some(chat2_id)).await?; diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 2f8e5db772..ae7e047d35 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -5,7 +5,7 @@ use tokio::fs; use super::*; use crate::chat::{ - ChatItem, ChatVisibility, add_contact_to_chat, add_to_chat_contacts_table, create_group_chat, + ChatItem, ChatVisibility, add_contact_to_chat, add_to_chat_contacts_table, create_group, get_chat_contacts, get_chat_msgs, is_contact_in_chat, remove_contact_from_chat, send_text_msg, }; use crate::chatlist::Chatlist; @@ -2944,7 +2944,7 @@ async fn test_outgoing_private_reply_multidevice() -> Result<()> { let charlie = tcm.charlie().await; // =============== Bob creates a group =============== - let group_id = chat::create_group_chat(&bob, "Group").await?; + let group_id = chat::create_group(&bob, "Group").await?; chat::add_to_chat_contacts_table( &bob, time(), @@ -3090,7 +3090,7 @@ async fn test_bot_accepts_another_group_after_qr_scan() -> Result<()> { let bob = &tcm.bob().await; bob.set_config(Config::Bot, Some("1")).await?; - let group_id = chat::create_group_chat(alice, "Group").await?; + let group_id = chat::create_group(alice, "Group").await?; let qr = get_securejoin_qr(alice, Some(group_id)).await?; tcm.exec_securejoin_qr(bob, alice, &qr).await; @@ -3148,7 +3148,7 @@ async fn test_no_private_reply_to_blocked_account() -> Result<()> { let bob = tcm.bob().await; tcm.section("Bob creates a group"); - let group_id = chat::create_group_chat(&bob, "Group").await?; + let group_id = chat::create_group(&bob, "Group").await?; chat::add_to_chat_contacts_table( &bob, time(), @@ -3720,7 +3720,7 @@ async fn test_unsigned_chat_group_hdr() -> Result<()> { let bob = &tcm.bob().await; let bob_addr = bob.get_config(Config::Addr).await?.unwrap(); let bob_id = alice.add_or_lookup_contact_id(bob).await; - let alice_chat_id = create_group_chat(alice, "foos").await?; + let alice_chat_id = create_group(alice, "foos").await?; add_contact_to_chat(alice, alice_chat_id, bob_id).await?; send_text_msg(alice, alice_chat_id, "populate".to_string()).await?; let sent_msg = alice.pop_sent_msg().await; @@ -3766,7 +3766,7 @@ async fn test_sync_member_list_on_rejoin() -> Result<()> { let bob_id = alice.add_or_lookup_contact_id(bob).await; let fiona_id = alice.add_or_lookup_contact_id(fiona).await; - let alice_chat_id = create_group_chat(alice, "foos").await?; + let alice_chat_id = create_group(alice, "foos").await?; add_contact_to_chat(alice, alice_chat_id, bob_id).await?; add_contact_to_chat(alice, alice_chat_id, fiona_id).await?; @@ -3804,7 +3804,7 @@ async fn test_ignore_outdated_membership_changes() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; let alice_bob_id = alice.add_or_lookup_contact_id(bob).await; - let alice_chat_id = create_group_chat(alice, "grp").await?; + let alice_chat_id = create_group(alice, "grp").await?; // Alice creates a group chat. Bob accepts it. add_contact_to_chat(alice, alice_chat_id, alice_bob_id).await?; @@ -3852,7 +3852,7 @@ async fn test_dont_recreate_contacts_on_add_remove() -> Result<()> { let fiona = &tcm.fiona().await; let charlie = &tcm.charlie().await; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; add_contact_to_chat( alice, @@ -3903,7 +3903,7 @@ async fn test_delayed_removal_is_ignored() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; let fiona = &tcm.fiona().await; - let chat_id = create_group_chat(alice, "Group").await?; + let chat_id = create_group(alice, "Group").await?; let alice_bob = alice.add_or_lookup_contact_id(bob).await; let alice_fiona = alice.add_or_lookup_contact_id(fiona).await; // create chat with three members @@ -3956,7 +3956,7 @@ async fn test_dont_readd_with_normal_msg() -> Result<()> { let bob = &tcm.bob().await; let fiona = &tcm.fiona().await; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; add_contact_to_chat( alice, @@ -4194,7 +4194,7 @@ async fn test_member_left_does_not_create_chat() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; add_contact_to_chat( alice, alice_chat_id, @@ -4222,7 +4222,7 @@ async fn test_recreate_member_list_on_missing_add_of_self() -> Result<()> { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; add_contact_to_chat( alice, alice_chat_id, @@ -4266,7 +4266,7 @@ async fn test_recreate_member_list_on_missing_add_of_self() -> Result<()> { async fn test_keep_member_list_if_possibly_nomember() -> Result<()> { let alice = TestContext::new_alice().await; let bob = TestContext::new_bob().await; - let alice_chat_id = create_group_chat(&alice, "Group").await?; + let alice_chat_id = create_group(&alice, "Group").await?; add_contact_to_chat( &alice, alice_chat_id, @@ -4406,7 +4406,7 @@ async fn test_create_group_with_big_msg() -> Result<()> { let file_bytes = include_bytes!("../../test-data/image/screenshot.png"); - let bob_grp_id = create_group_chat(&bob, "Group").await?; + let bob_grp_id = create_group(&bob, "Group").await?; add_contact_to_chat(&bob, bob_grp_id, ba_contact).await?; let mut msg = Message::new(Viewtype::Image); msg.set_file_from_bytes(&bob, "a.jpg", file_bytes, None)?; @@ -4437,7 +4437,7 @@ async fn test_create_group_with_big_msg() -> Result<()> { // Now Bob can send encrypted messages to Alice. - let bob_grp_id = create_group_chat(&bob, "Group1").await?; + let bob_grp_id = create_group(&bob, "Group1").await?; add_contact_to_chat(&bob, bob_grp_id, ba_contact).await?; let mut msg = Message::new(Viewtype::Image); msg.set_file_from_bytes(&bob, "a.jpg", file_bytes, None)?; @@ -4478,7 +4478,7 @@ async fn test_partial_group_consistency() -> Result<()> { let bob = tcm.bob().await; let fiona = tcm.fiona().await; let bob_id = alice.add_or_lookup_contact_id(&bob).await; - let alice_chat_id = create_group_chat(&alice, "foos").await?; + let alice_chat_id = create_group(&alice, "foos").await?; add_contact_to_chat(&alice, alice_chat_id, bob_id).await?; send_text_msg(&alice, alice_chat_id, "populate".to_string()).await?; @@ -4558,7 +4558,7 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; mark_as_verified(alice, bob).await; - let group_id = create_group_chat(alice, "Group").await?; + let group_id = create_group(alice, "Group").await?; let alice_bob_id = alice.add_or_lookup_contact(bob).await.id; add_contact_to_chat(alice, group_id, alice_bob_id).await?; alice.send_text(group_id, "Hello!").await; @@ -4655,7 +4655,7 @@ async fn test_unarchive_on_member_removal() -> Result<()> { let fiona = &tcm.fiona().await; let bob_id = alice.add_or_lookup_contact_id(bob).await; let fiona_id = alice.add_or_lookup_contact_id(fiona).await; - let alice_chat_id = create_group_chat(alice, "foos").await?; + let alice_chat_id = create_group(alice, "foos").await?; add_contact_to_chat(alice, alice_chat_id, bob_id).await?; add_contact_to_chat(alice, alice_chat_id, fiona_id).await?; @@ -4755,7 +4755,7 @@ async fn test_references() -> Result<()> { let bob = &tcm.bob().await; alice.set_config_bool(Config::BccSelf, true).await?; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; alice .send_text(alice_chat_id, "Hi! I created a group.") .await; @@ -4799,7 +4799,7 @@ async fn test_prefer_references_to_downloaded_msgs() -> Result<()> { let fiona = &tcm.fiona().await; let alice_bob_id = tcm.send_recv(bob, alice, "hi").await.from_id; let alice_fiona_id = tcm.send_recv(fiona, alice, "hi").await.from_id; - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; add_contact_to_chat(alice, alice_chat_id, alice_bob_id).await?; // W/o fiona the test doesn't work -- the last message is assigned to the 1:1 chat due to // `is_probably_private_reply()`. @@ -4999,7 +4999,7 @@ async fn test_group_name_with_newline() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let chat_id = create_group_chat(alice, "Group\r\nwith\nnewlines").await?; + let chat_id = create_group(alice, "Group\r\nwith\nnewlines").await?; add_contact_to_chat(alice, chat_id, alice.add_or_lookup_contact_id(bob).await).await?; send_text_msg(alice, chat_id, "populate".to_string()).await?; let bob_chat_id = bob.recv_msg(&alice.pop_sent_msg().await).await.chat_id; @@ -5017,7 +5017,7 @@ async fn test_rename_chat_on_missing_message() -> Result<()> { let alice = tcm.alice().await; let bob = tcm.bob().await; let charlie = tcm.charlie().await; - let chat_id = create_group_chat(&alice, "Group").await?; + let chat_id = create_group(&alice, "Group").await?; add_to_chat_contacts_table( &alice, time(), @@ -5053,7 +5053,7 @@ async fn test_rename_chat_after_creating_invite() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; for populate_before_securejoin in [false, true] { - let alice_chat_id = create_group_chat(alice, "Group").await?; + let alice_chat_id = create_group(alice, "Group").await?; let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await?; SystemTime::shift(Duration::from_secs(60)); @@ -5083,7 +5083,7 @@ async fn test_two_group_securejoins() -> Result<()> { let bob = &tcm.bob().await; let fiona = &tcm.fiona().await; - let group_id = chat::create_group_chat(alice, "Group").await?; + let group_id = chat::create_group(alice, "Group").await?; let qr = get_securejoin_qr(alice, Some(group_id)).await?; @@ -5108,7 +5108,7 @@ async fn test_unverified_member_msg() -> Result<()> { let bob = &tcm.bob().await; let fiona = &tcm.fiona().await; - let alice_chat_id = chat::create_group_chat(alice, "Group").await?; + let alice_chat_id = chat::create_group(alice, "Group").await?; let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await?; tcm.exec_securejoin_qr(bob, alice, &qr).await; @@ -5134,7 +5134,7 @@ async fn test_dont_reverify_by_self_on_outgoing_msg() -> Result<()> { let bob = &tcm.bob().await; let fiona = &tcm.fiona().await; - let bob_chat_id = chat::create_group_chat(bob, "Group").await?; + let bob_chat_id = chat::create_group(bob, "Group").await?; let qr = get_securejoin_qr(bob, Some(bob_chat_id)).await?; tcm.exec_securejoin_qr(fiona, bob, &qr).await; tcm.exec_securejoin_qr(a0, bob, &qr).await; @@ -5478,7 +5478,7 @@ async fn test_small_unencrypted_group() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_chat_id = chat::create_group_chat_unencrypted(alice, "Unencrypted group").await?; + let alice_chat_id = chat::create_group_unencrypted(alice, "Unencrypted group").await?; let alice_bob_id = alice.add_or_lookup_address_contact_id(bob).await; add_contact_to_chat(alice, alice_chat_id, alice_bob_id).await?; send_text_msg(alice, alice_chat_id, "Hello!".to_string()).await?; diff --git a/src/securejoin/securejoin_tests.rs b/src/securejoin/securejoin_tests.rs index 05a1060c4c..6527cfe791 100644 --- a/src/securejoin/securejoin_tests.rs +++ b/src/securejoin/securejoin_tests.rs @@ -436,7 +436,7 @@ async fn test_secure_join() -> Result<()> { assert_eq!(Chatlist::try_load(&alice, 0, None, None).await?.len(), 0); assert_eq!(Chatlist::try_load(&bob, 0, None, None).await?.len(), 0); - let alice_chatid = chat::create_group_chat(&alice, "the chat").await?; + let alice_chatid = chat::create_group(&alice, "the chat").await?; tcm.section("Step 1: Generate QR-code, secure-join implied by chatid"); let qr = get_securejoin_qr(&alice, Some(alice_chatid)).await.unwrap(); @@ -722,8 +722,8 @@ async fn test_parallel_securejoin() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_chat1_id = chat::create_group_chat(alice, "First chat").await?; - let alice_chat2_id = chat::create_group_chat(alice, "Second chat").await?; + let alice_chat1_id = chat::create_group(alice, "First chat").await?; + let alice_chat2_id = chat::create_group(alice, "Second chat").await?; let qr1 = get_securejoin_qr(alice, Some(alice_chat1_id)).await?; let qr2 = get_securejoin_qr(alice, Some(alice_chat2_id)).await?; @@ -890,7 +890,7 @@ async fn test_expired_group_auth_token() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_chat_id = chat::create_group_chat(alice, "Group").await?; + let alice_chat_id = chat::create_group(alice, "Group").await?; // Alice creates a group QR code. let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await.unwrap(); diff --git a/src/sync.rs b/src/sync.rs index e1e5a1c54c..05d139b778 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -721,7 +721,7 @@ mod tests { let mut tcm = TestContextManager::new(); let alice = &tcm.alice().await; alice.set_config_bool(Config::SyncMsgs, true).await?; - let alice_chatid = chat::create_group_chat(alice, "the chat").await?; + let alice_chatid = chat::create_group(alice, "the chat").await?; let qr = get_securejoin_qr(alice, Some(alice_chatid)).await?; // alice2 syncs the QR code token. diff --git a/src/test_utils.rs b/src/test_utils.rs index f50fcdbfa0..11aec0021b 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -21,8 +21,7 @@ use tokio::runtime::Handle; use tokio::{fs, task}; use crate::chat::{ - self, Chat, ChatId, ChatIdBlocked, MessageListOptions, add_to_chat_contacts_table, - create_group_chat, + self, Chat, ChatId, ChatIdBlocked, MessageListOptions, add_to_chat_contacts_table, create_group, }; use crate::chatlist::Chatlist; use crate::config::Config; @@ -1057,7 +1056,7 @@ impl TestContext { chat_name: &str, members: &[&TestContext], ) -> ChatId { - let chat_id = create_group_chat(self, chat_name).await.unwrap(); + let chat_id = create_group(self, chat_name).await.unwrap(); let mut to_add = vec![]; for member in members { let contact_id = self.add_or_lookup_contact_id(member).await; diff --git a/src/tests/aeap.rs b/src/tests/aeap.rs index 51316efc50..166a83857f 100644 --- a/src/tests/aeap.rs +++ b/src/tests/aeap.rs @@ -90,12 +90,12 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition, verified: } let mut groups = vec![ - chat::create_group_chat(bob, "Group 0").await.unwrap(), - chat::create_group_chat(bob, "Group 1").await.unwrap(), + chat::create_group(bob, "Group 0").await.unwrap(), + chat::create_group(bob, "Group 1").await.unwrap(), ]; if verified { - groups.push(chat::create_group_chat(bob, "Group 2").await.unwrap()); - groups.push(chat::create_group_chat(bob, "Group 3").await.unwrap()); + groups.push(chat::create_group(bob, "Group 2").await.unwrap()); + groups.push(chat::create_group(bob, "Group 3").await.unwrap()); } let alice_contact = bob.add_or_lookup_contact_id(alice).await; @@ -189,7 +189,7 @@ async fn test_aeap_replay_attack() -> Result<()> { tcm.send_recv_accept(&alice, &bob, "Hi").await; tcm.send_recv(&bob, &alice, "Hi back").await; - let group = chat::create_group_chat(&bob, "Group 0").await?; + let group = chat::create_group(&bob, "Group 0").await?; let bob_alice_contact = bob.add_or_lookup_contact_id(&alice).await; let bob_fiona_contact = bob.add_or_lookup_contact_id(&fiona).await; @@ -230,7 +230,7 @@ async fn test_write_to_alice_after_aeap() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; - let alice_grp_id = chat::create_group_chat(alice, "Group").await?; + let alice_grp_id = chat::create_group(alice, "Group").await?; let qr = get_securejoin_qr(alice, Some(alice_grp_id)).await?; tcm.exec_securejoin_qr(bob, alice, &qr).await; let bob_alice_contact = bob.add_or_lookup_contact(alice).await; diff --git a/src/webxdc/maps_integration.rs b/src/webxdc/maps_integration.rs index 6fa9a85401..3ee931a599 100644 --- a/src/webxdc/maps_integration.rs +++ b/src/webxdc/maps_integration.rs @@ -169,7 +169,7 @@ pub(crate) async fn intercept_get_updates( #[cfg(test)] mod tests { - use crate::chat::{ChatId, create_group_chat}; + use crate::chat::{ChatId, create_group}; use crate::chatlist::Chatlist; use crate::contact::Contact; use crate::message::Message; @@ -231,7 +231,7 @@ mod tests { assert_eq!(msg.chat_id, bob_chat_id); // Integrate Webxdc into another group - let group_id = create_group_chat(&t, "foo").await?; + let group_id = create_group(&t, "foo").await?; let integration_id = t.init_webxdc_integration(Some(group_id)).await?.unwrap(); let locations = location::get_range(&t, Some(group_id), None, 0, 0).await?; diff --git a/src/webxdc/webxdc_tests.rs b/src/webxdc/webxdc_tests.rs index 354675ee07..cc205f3fc9 100644 --- a/src/webxdc/webxdc_tests.rs +++ b/src/webxdc/webxdc_tests.rs @@ -5,7 +5,7 @@ use serde_json::json; use super::*; use crate::chat::{ - ChatId, add_contact_to_chat, create_broadcast, create_group_chat, forward_msgs, + ChatId, add_contact_to_chat, create_broadcast, create_group, forward_msgs, remove_contact_from_chat, resend_msgs, send_msg, send_text_msg, }; use crate::chatlist::Chatlist; @@ -78,7 +78,7 @@ async fn send_webxdc_instance(t: &TestContext, chat_id: ChatId) -> Result Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; // send as .xdc file let instance = send_webxdc_instance(&t, chat_id).await?; @@ -97,7 +97,7 @@ async fn test_send_webxdc_instance() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_send_invalid_webxdc() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; // sending invalid .xdc as file is possible, but must not result in Viewtype::Webxdc let mut instance = create_webxdc_instance( @@ -126,7 +126,7 @@ async fn test_send_invalid_webxdc() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_set_draft_invalid_webxdc() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let mut instance = create_webxdc_instance( &t, @@ -143,7 +143,7 @@ async fn test_set_draft_invalid_webxdc() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_send_special_webxdc_format() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; // chess.xdc is failing for some zip-versions, see #3476, if we know more details about why, we can have a nicer name for the test :) let mut instance = create_webxdc_instance( @@ -164,7 +164,7 @@ async fn test_send_special_webxdc_format() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_forward_webxdc_instance() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; t.send_webxdc_status_update( instance.id, @@ -213,7 +213,7 @@ async fn test_resend_webxdc_instance_and_info() -> Result<()> { // Alice uses webxdc in a group alice.set_config_bool(Config::BccSelf, false).await?; - let alice_grp = create_group_chat(&alice, "grp").await?; + let alice_grp = create_group(&alice, "grp").await?; let alice_instance = send_webxdc_instance(&alice, alice_grp).await?; assert_eq!(alice_grp.get_msg_cnt(&alice).await?, 2); alice @@ -395,7 +395,7 @@ async fn test_webxdc_update_for_not_downloaded_instance() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_delete_webxdc_instance() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let now = tools::time(); t.receive_status_update( @@ -428,7 +428,7 @@ async fn test_delete_webxdc_instance() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_delete_chat_with_webxdc() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let now = tools::time(); t.receive_status_update( @@ -461,7 +461,7 @@ async fn test_delete_chat_with_webxdc() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_delete_webxdc_draft() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let mut instance = create_webxdc_instance( &t, @@ -498,7 +498,7 @@ async fn test_delete_webxdc_draft() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_create_status_update_record() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; assert_eq!( @@ -633,7 +633,7 @@ async fn test_create_status_update_record() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_receive_status_update() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let now = tools::time(); @@ -904,7 +904,7 @@ async fn test_send_big_webxdc_status_update() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_render_webxdc_status_update_object() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "a chat").await?; + let chat_id = create_group(&t, "a chat").await?; let mut instance = create_webxdc_instance( &t, "minimal.xdc", @@ -932,7 +932,7 @@ async fn test_render_webxdc_status_update_object() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_render_webxdc_status_update_object_range() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "a chat").await?; + let chat_id = create_group(&t, "a chat").await?; let instance = send_webxdc_instance(&t, chat_id).await?; t.send_webxdc_status_update(instance.id, r#"{"payload": 1}"#) .await?; @@ -979,7 +979,7 @@ async fn test_render_webxdc_status_update_object_range() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_pop_status_update() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "a chat").await?; + let chat_id = create_group(&t, "a chat").await?; let instance1 = send_webxdc_instance(&t, chat_id).await?; let instance2 = send_webxdc_instance(&t, chat_id).await?; let instance3 = send_webxdc_instance(&t, chat_id).await?; @@ -1109,7 +1109,7 @@ async fn test_draft_and_send_webxdc_status_update() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_send_webxdc_status_update_to_non_webxdc() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let msg_id = send_text_msg(&t, chat_id, "ho!".to_string()).await?; assert!( t.send_webxdc_status_update(msg_id, r#"{"foo":"bar"}"#) @@ -1122,7 +1122,7 @@ async fn test_send_webxdc_status_update_to_non_webxdc() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_blob() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let buf = instance.get_webxdc_blob(&t, "index.html").await?; @@ -1141,7 +1141,7 @@ async fn test_get_webxdc_blob() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_blob_default_icon() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let buf = instance.get_webxdc_blob(&t, WEBXDC_DEFAULT_ICON).await?; @@ -1153,7 +1153,7 @@ async fn test_get_webxdc_blob_default_icon() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_blob_with_absolute_paths() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let buf = instance.get_webxdc_blob(&t, "/index.html").await?; @@ -1166,7 +1166,7 @@ async fn test_get_webxdc_blob_with_absolute_paths() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_blob_with_subdirs() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let mut instance = create_webxdc_instance( &t, "some-files.xdc", @@ -1265,7 +1265,7 @@ async fn test_parse_webxdc_manifest_source_code_url() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_webxdc_min_api_too_large() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "chat").await?; + let chat_id = create_group(&t, "chat").await?; let mut instance = create_webxdc_instance( &t, "with-min-api-1001.xdc", @@ -1283,7 +1283,7 @@ async fn test_webxdc_min_api_too_large() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_info() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let info = instance.get_webxdc_info(&t).await?; @@ -1363,7 +1363,7 @@ async fn test_get_webxdc_info() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_webxdc_self_addr() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "foo").await?; + let chat_id = create_group(&t, "foo").await?; let instance = send_webxdc_instance(&t, chat_id).await?; let info1 = instance.get_webxdc_info(&t).await?; @@ -1601,7 +1601,7 @@ async fn test_webxdc_info_msg_cleanup_series() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_webxdc_info_msg_no_cleanup_on_interrupted_series() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "c").await?; + let chat_id = create_group(&t, "c").await?; let instance = send_webxdc_instance(&t, chat_id).await?; t.send_webxdc_status_update(instance.id, r#"{"info":"i1", "payload":1}"#) @@ -1623,7 +1623,7 @@ async fn test_webxdc_no_internet_access() -> Result<()> { let t = TestContext::new_alice().await; let self_id = t.get_self_chat().await.id; let single_id = t.create_chat_with_contact("bob", "bob@e.com").await.id; - let group_id = create_group_chat(&t, "chat").await?; + let group_id = create_group(&t, "chat").await?; let broadcast_id = create_broadcast(&t, "Channel".to_string()).await?; for chat_id in [self_id, single_id, group_id, broadcast_id] { @@ -1655,7 +1655,7 @@ async fn test_webxdc_no_internet_access() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_webxdc_chatlist_summary() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, "chat").await?; + let chat_id = create_group(&t, "chat").await?; let mut instance = create_webxdc_instance( &t, "with-minimal-manifest.xdc", @@ -1727,7 +1727,7 @@ async fn test_webxdc_reject_updates_from_non_groupmembers() -> Result<()> { let alice = &tcm.alice().await; let bob = &tcm.bob().await; let contact_bob = alice.add_or_lookup_contact_id(bob).await; - let chat_id = create_group_chat(alice, "Group").await?; + let chat_id = create_group(alice, "Group").await?; add_contact_to_chat(alice, chat_id, contact_bob).await?; let instance = send_webxdc_instance(alice, chat_id).await?; bob.recv_msg(&alice.pop_sent_msg().await).await; @@ -1758,7 +1758,7 @@ async fn test_webxdc_reject_updates_from_non_groupmembers() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_webxdc_delete_event() -> Result<()> { let alice = TestContext::new_alice().await; - let chat_id = create_group_chat(&alice, "foo").await?; + let chat_id = create_group(&alice, "foo").await?; let instance = send_webxdc_instance(&alice, chat_id).await?; message::delete_msgs(&alice, &[instance.id]).await?; alice