mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fix: Make broadcast owner and subscriber hidden contacts for each other (#7856)
This commit is contained in:
@@ -257,7 +257,11 @@ impl ChatId {
|
|||||||
ChatIdBlocked::get_for_contact(context, contact_id, create_blocked)
|
ChatIdBlocked::get_for_contact(context, contact_id, create_blocked)
|
||||||
.await
|
.await
|
||||||
.map(|chat| chat.id)?;
|
.map(|chat| chat.id)?;
|
||||||
ContactId::scaleup_origin(context, &[contact_id], Origin::CreateChat).await?;
|
if create_blocked != Blocked::Yes {
|
||||||
|
info!(context, "Scale up origin of {contact_id} to CreateChat.");
|
||||||
|
ContactId::scaleup_origin(context, &[contact_id], Origin::CreateChat)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
chat_id
|
chat_id
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(
|
||||||
|
|||||||
@@ -4835,6 +4835,22 @@ async fn test_sync_create_group() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_broadcast_contacts_are_hidden() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let alice = &tcm.alice().await;
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
|
||||||
|
let alice_chat_id = create_broadcast(alice, "Channel".to_string()).await?;
|
||||||
|
let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await?;
|
||||||
|
tcm.exec_securejoin_qr(bob, alice, &qr).await;
|
||||||
|
send_text_msg(alice, alice_chat_id, "hello".to_string()).await?;
|
||||||
|
bob.recv_msg(&alice.pop_sent_msg().await).await;
|
||||||
|
assert_eq!(Contact::get_all(alice, 0, None).await?.len(), 0);
|
||||||
|
assert_eq!(Contact::get_all(bob, 0, None).await?.len(), 0);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Tests sending JPEG image with .png extension.
|
/// Tests sending JPEG image with .png extension.
|
||||||
///
|
///
|
||||||
/// This is a regression test, previously sending failed
|
/// This is a regression test, previously sending failed
|
||||||
|
|||||||
@@ -456,9 +456,16 @@ impl MimeFactory {
|
|||||||
.filter(|id| *id != ContactId::SELF)
|
.filter(|id| *id != ContactId::SELF)
|
||||||
.collect();
|
.collect();
|
||||||
if recipient_ids.len() == 1
|
if recipient_ids.len() == 1
|
||||||
&& msg.param.get_cmd() != SystemMessage::MemberRemovedFromGroup
|
&& !matches!(
|
||||||
&& chat.typ != Chattype::OutBroadcast
|
msg.param.get_cmd(),
|
||||||
|
SystemMessage::MemberRemovedFromGroup | SystemMessage::SecurejoinMessage
|
||||||
|
)
|
||||||
|
&& !matches!(chat.typ, Chattype::OutBroadcast | Chattype::InBroadcast)
|
||||||
{
|
{
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"Scale up origin of {} recipients to OutgoingTo.", chat.id
|
||||||
|
);
|
||||||
ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?;
|
ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -641,15 +641,12 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
mark_contact_id_as_verified(context, contact_id, Some(ContactId::SELF)).await?;
|
mark_contact_id_as_verified(context, contact_id, Some(ContactId::SELF)).await?;
|
||||||
}
|
}
|
||||||
contact_id.regossip_keys(context).await?;
|
contact_id.regossip_keys(context).await?;
|
||||||
ContactId::scaleup_origin(context, &[contact_id], Origin::SecurejoinInvited).await?;
|
|
||||||
// for setup-contact, make Alice's one-to-one chat with Bob visible
|
// for setup-contact, make Alice's one-to-one chat with Bob visible
|
||||||
// (secure-join-information are shown in the group chat)
|
// (secure-join-information are shown in the group chat)
|
||||||
if grpid.is_empty() {
|
if grpid.is_empty() {
|
||||||
ChatId::create_for_contact(context, contact_id).await?;
|
ChatId::create_for_contact(context, contact_id).await?;
|
||||||
}
|
}
|
||||||
context.emit_event(EventType::ContactsChanged(Some(contact_id)));
|
|
||||||
if let Some(joining_chat_id) = joining_chat_id {
|
if let Some(joining_chat_id) = joining_chat_id {
|
||||||
// Join group.
|
|
||||||
chat::add_contact_to_chat_ex(context, Nosync, joining_chat_id, contact_id, true)
|
chat::add_contact_to_chat_ex(context, Nosync, joining_chat_id, contact_id, true)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@@ -659,6 +656,10 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
// We don't use the membership consistency algorithm for broadcast channels,
|
// We don't use the membership consistency algorithm for broadcast channels,
|
||||||
// so, sync the memberlist when adding a contact
|
// so, sync the memberlist when adding a contact
|
||||||
chat.sync_contacts(context).await.log_err(context).ok();
|
chat.sync_contacts(context).await.log_err(context).ok();
|
||||||
|
} else {
|
||||||
|
ContactId::scaleup_origin(context, &[contact_id], Origin::SecurejoinInvited)
|
||||||
|
.await?;
|
||||||
|
context.emit_event(EventType::ContactsChanged(Some(contact_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inviter_progress(context, contact_id, joining_chat_id, chat.typ)?;
|
inviter_progress(context, contact_id, joining_chat_id, chat.typ)?;
|
||||||
|
|||||||
@@ -49,8 +49,14 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul
|
|||||||
// receive_imf.
|
// receive_imf.
|
||||||
let private_chat_id = private_chat_id(context, &invite).await?;
|
let private_chat_id = private_chat_id(context, &invite).await?;
|
||||||
|
|
||||||
ContactId::scaleup_origin(context, &[invite.contact_id()], Origin::SecurejoinJoined).await?;
|
match invite {
|
||||||
|
QrInvite::Group { .. } | QrInvite::Contact { .. } => {
|
||||||
|
ContactId::scaleup_origin(context, &[invite.contact_id()], Origin::SecurejoinJoined)
|
||||||
|
.await?;
|
||||||
context.emit_event(EventType::ContactsChanged(None));
|
context.emit_event(EventType::ContactsChanged(None));
|
||||||
|
}
|
||||||
|
QrInvite::Broadcast { .. } => {}
|
||||||
|
}
|
||||||
|
|
||||||
let has_key = context
|
let has_key = context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
Reference in New Issue
Block a user