fix suggested changes

This commit is contained in:
Septias
2022-12-11 11:39:53 +01:00
committed by Sebastian Klähn
parent 8d077b964c
commit 7415eadb78
2 changed files with 19 additions and 24 deletions

View File

@@ -3565,8 +3565,7 @@ mod tests {
use crate::constants::{DC_GCL_ARCHIVED_ONLY, DC_GCL_NO_SPECIALS};
use crate::contact::Contact;
use crate::receive_imf::receive_imf;
use crate::test_utils::TestContext;
use crate::test_utils::{TestContext, TestContextManager};
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_chat_info() {
@@ -3963,18 +3962,20 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_member_list_on_rejoin() -> Result<()> {
let alice = TestContext::new_alice().await;
let mut tcm = TestContextManager::new();
let alice = tcm.alice().await;
let bob_id = Contact::create(&alice, "", "bob@example.net").await?;
let claire_id = Contact::create(&alice, "", "claire@example.de").await?;
let alice_chat_id = create_group_chat(&alice, ProtectionStatus::Unprotected, "foos").await?;
let alice_chat_id =
create_group_chat(&alice, ProtectionStatus::Unprotected, "foos").await?;
add_contact_to_chat(&alice, alice_chat_id, bob_id).await?;
add_contact_to_chat(&alice, alice_chat_id, claire_id).await?;
send_text_msg(&alice, alice_chat_id, "populate".to_string()).await?;
let add = alice.pop_sent_msg().await;
let bob = TestContext::new_bob().await;
let bob = tcm.bob().await;
bob.recv_msg(&add).await;
let bob_chat_id = bob.get_last_msg().await.chat_id;
assert_eq!(get_chat_contacts(&bob, bob_chat_id).await?.len(), 3);

View File

@@ -1601,7 +1601,12 @@ async fn apply_group_changes(
return Ok(None);
}
let mut recreate_member_list = false;
let mut recreate_member_list = match mime_parser.get_header(HeaderDef::InReplyTo) {
Some(reply_to) if rfc724_mid_exists(context, reply_to).await?.is_none() => true,
Some(_) => false,
None => true,
};
let mut send_event_chat_modified = false;
let mut better_msg = None;
@@ -1613,12 +1618,6 @@ async fn apply_group_changes(
removed_id = Contact::lookup_id_by_addr(context, &removed_addr, Origin::Unknown).await?;
match removed_id {
Some(contact_id) => {
recreate_member_list = match mime_parser.get_header(HeaderDef::InReplyTo) {
Some(reply_to) if rfc724_mid_exists(context, reply_to).await?.is_none() => true,
Some(_) => false,
None => true,
};
if !recreate_member_list {
chat::remove_from_chat_contacts_table(context, chat_id, contact_id).await?;
chat_id
@@ -1646,24 +1645,19 @@ async fn apply_group_changes(
{
better_msg = Some(stock_str::msg_add_member(context, &added_member, from_id).await);
if let Some(contact_id) =
Contact::lookup_id_by_addr(context, &added_member, Origin::Unknown).await?
{
recreate_member_list = match mime_parser.get_header(HeaderDef::InReplyTo) {
Some(reply_to) if rfc724_mid_exists(context, reply_to).await?.is_none() => true,
Some(_) => false,
None => true,
};
warn!(context, "recreating: {}", recreate_member_list);
if !recreate_member_list {
warn!(context, "recreating: {}", recreate_member_list);
if !recreate_member_list {
if let Some(contact_id) =
Contact::lookup_id_by_addr(context, &added_member, Origin::Unknown).await?
{
chat::add_to_chat_contacts_table(context, chat_id, &[contact_id]).await?;
chat_id
.update_timestamp(context, Param::MemberListTimestamp, sent_timestamp)
.await?;
send_event_chat_modified = true;
} else {
recreate_member_list = true;
}
} else {
recreate_member_list = true;
}
} else if let Some(old_name) = mime_parser
.get_header(HeaderDef::ChatGroupNameChanged)