send setup-changed messages only in the chats we share with the peer, do not create contact request

This commit is contained in:
adbenitez
2022-04-04 01:05:49 -04:00
parent de91063fbe
commit e29d008914

View File

@@ -4,8 +4,8 @@ use std::collections::HashSet;
use std::fmt; use std::fmt;
use crate::aheader::{Aheader, EncryptPreference}; use crate::aheader::{Aheader, EncryptPreference};
use crate::chat::{self, ChatIdBlocked}; use crate::chat::{self};
use crate::constants::Blocked; use crate::chatlist::Chatlist;
use crate::context::Context; use crate::context::Context;
use crate::events::EventType; use crate::events::EventType;
use crate::key::{DcKey, Fingerprint, SignedPublicKey}; use crate::key::{DcKey, Fingerprint, SignedPublicKey};
@@ -271,14 +271,15 @@ impl Peerstate {
.query_get_value("SELECT id FROM contacts WHERE addr=?;", paramsv![self.addr]) .query_get_value("SELECT id FROM contacts WHERE addr=?;", paramsv![self.addr])
.await? .await?
{ {
let chat_id = ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Request) let chats = Chatlist::try_load(context, 0, None, contact_id)
.await? .await
.id; .unwrap();
let msg = stock_str::contact_setup_changed(context, self.addr.clone()).await; let msg = stock_str::contact_setup_changed(context, self.addr.clone()).await;
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?; chat::add_info_msg(context, chat_id, &msg, timestamp).await?;
context.emit_event(EventType::ChatModified(chat_id)); context.emit_event(EventType::ChatModified(chat_id));
}
} else { } else {
bail!("contact with peerstate.addr {:?} not found", &self.addr); bail!("contact with peerstate.addr {:?} not found", &self.addr);
} }