mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
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.
This commit is contained in:
@@ -1730,7 +1730,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())
|
||||
|
||||
@@ -968,9 +968,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<u32> {
|
||||
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.
|
||||
@@ -979,7 +977,7 @@ impl CommandApi {
|
||||
/// address-contacts.
|
||||
async fn create_group_chat_unencrypted(&self, account_id: u32, name: String) -> Result<u32> {
|
||||
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())
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
||||
}
|
||||
"creategroup" => {
|
||||
ensure!(!arg1.is_empty(), "Argument <name> 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.");
|
||||
}
|
||||
|
||||
@@ -3401,12 +3401,12 @@ 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<ChatId> {
|
||||
pub async fn create_group(context: &Context, name: &str) -> Result<ChatId> {
|
||||
create_group_ex(context, Sync, create_id(), name).await
|
||||
}
|
||||
|
||||
/// Creates an unencrypted group chat.
|
||||
pub async fn create_group_chat_unencrypted(context: &Context, name: &str) -> Result<ChatId> {
|
||||
pub async fn create_group_unencrypted(context: &Context, name: &str) -> Result<ChatId> {
|
||||
create_group_ex(context, Sync, String::new(), name).await
|
||||
}
|
||||
|
||||
@@ -3479,7 +3479,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<ChatId> {
|
||||
|
||||
@@ -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<message::Message> = (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, 0x6239dc);
|
||||
|
||||
// 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?
|
||||
@@ -3100,7 +3100,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"
|
||||
@@ -3180,8 +3180,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(
|
||||
@@ -3405,7 +3405,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?;
|
||||
@@ -3844,7 +3844,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)
|
||||
@@ -4119,7 +4119,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?;
|
||||
|
||||
@@ -4163,7 +4163,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.")
|
||||
@@ -4197,7 +4197,7 @@ async fn test_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.")
|
||||
@@ -4240,7 +4240,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);
|
||||
@@ -4271,7 +4271,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.")
|
||||
@@ -4308,7 +4308,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?;
|
||||
@@ -4370,7 +4370,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?;
|
||||
|
||||
@@ -4729,7 +4729,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;
|
||||
|
||||
@@ -4788,7 +4788,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;
|
||||
|
||||
@@ -4809,7 +4809,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(())
|
||||
@@ -4855,7 +4855,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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -118,7 +118,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,
|
||||
|
||||
@@ -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?;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -962,7 +962,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);
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -432,7 +432,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();
|
||||
@@ -715,8 +715,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?;
|
||||
@@ -883,7 +883,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();
|
||||
|
||||
@@ -728,7 +728,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.
|
||||
|
||||
@@ -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;
|
||||
@@ -1111,7 +1110,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;
|
||||
|
||||
@@ -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;
|
||||
@@ -232,7 +232,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;
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -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<Messag
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_send_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?;
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user