From e29d008914d112cfa04c22d4ce9024ba7c87f0e7 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 4 Apr 2022 01:05:49 -0400 Subject: [PATCH] send setup-changed messages only in the chats we share with the peer, do not create contact request --- src/peerstate.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/peerstate.rs b/src/peerstate.rs index 2dbc9a228..fdeed903b 100644 --- a/src/peerstate.rs +++ b/src/peerstate.rs @@ -4,8 +4,8 @@ use std::collections::HashSet; use std::fmt; use crate::aheader::{Aheader, EncryptPreference}; -use crate::chat::{self, ChatIdBlocked}; -use crate::constants::Blocked; +use crate::chat::{self}; +use crate::chatlist::Chatlist; use crate::context::Context; use crate::events::EventType; use crate::key::{DcKey, Fingerprint, SignedPublicKey}; @@ -271,14 +271,15 @@ impl Peerstate { .query_get_value("SELECT id FROM contacts WHERE addr=?;", paramsv![self.addr]) .await? { - let chat_id = ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Request) - .await? - .id; - + let chats = Chatlist::try_load(context, 0, None, contact_id) + .await + .unwrap(); let msg = stock_str::contact_setup_changed(context, self.addr.clone()).await; - - chat::add_info_msg(context, chat_id, &msg, timestamp).await?; - context.emit_event(EventType::ChatModified(chat_id)); + for chat_index in 0..chats.len() { + let chat_id = chats.get_chat_id(chat_index).unwrap(); + chat::add_info_msg(context, chat_id, &msg, timestamp).await?; + context.emit_event(EventType::ChatModified(chat_id)); + } } else { bail!("contact with peerstate.addr {:?} not found", &self.addr); }