don't always build new contact list

This commit is contained in:
Sebastian Klähn
2022-12-02 19:53:57 +01:00
parent c562d17925
commit 81695d6b80
2 changed files with 24 additions and 4 deletions

View File

@@ -57,6 +57,8 @@ pub struct MimeMessage {
/// Whether the From address was repeated in the signed part
/// (and we know that the signer intended to send from this address)
pub from_is_signed: bool,
/// The list post message is only set for messaging lists and is the address
/// where users can send messages to which will be posted in the list
pub list_post: Option<String>,
pub chat_disposition_notification_to: Option<SingleInfo>,
pub decryption_info: DecryptionInfo,

View File

@@ -12,7 +12,10 @@ use num_traits::FromPrimitive;
use once_cell::sync::Lazy;
use regex::Regex;
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, ProtectionStatus};
use crate::chat::{
self, add_contact_to_chat, remove_contact_from_chat, Chat, ChatId, ChatIdBlocked,
ProtectionStatus,
};
use crate::config::Config;
use crate::constants::{Blocked, Chattype, ShowEmails, DC_CHAT_ID_TRASH};
use crate::contact::{
@@ -1611,9 +1614,13 @@ async fn apply_group_changes(
.cloned()
{
removed_id = Contact::lookup_id_by_addr(context, &removed_addr, Origin::Unknown).await?;
recreate_member_list = true;
match removed_id {
Some(contact_id) => {
if mime_parser.get_header(HeaderDef::InReplyTo).is_none() {
recreate_member_list = true;
} else {
remove_contact_from_chat(context, chat_id, contact_id).await?
}
better_msg = if contact_id == from_id {
Some(stock_str::msg_group_left(context, from_id).await)
} else {
@@ -1621,7 +1628,7 @@ async fn apply_group_changes(
};
}
None => warn!(context, "removed {:?} has no contact_id", removed_addr),
}
};
} else {
removed_id = None;
if let Some(added_member) = mime_parser
@@ -1629,7 +1636,18 @@ async fn apply_group_changes(
.cloned()
{
better_msg = Some(stock_str::msg_add_member(context, &added_member, from_id).await);
recreate_member_list = true;
if let Some(contact_id) =
Contact::lookup_id_by_addr(context, &added_member, Origin::Unknown).await?
{
if mime_parser.get_header(HeaderDef::InReplyTo).is_none() {
recreate_member_list = true;
} else {
add_contact_to_chat(context, chat_id, contact_id).await?
}
} else {
recreate_member_list = true;
}
} else if let Some(old_name) = mime_parser
.get_header(HeaderDef::ChatGroupNameChanged)
// See create_or_lookup_group() for explanation