diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 37f62188c..f53683dc8 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -894,7 +894,7 @@ int dc_preconfigure_keypair (dc_context_t* context, const cha * the pseudo-chat DC_CHAT_ID_ARCHIVED_LINK is added if there are _any_ archived * chats * - the flag DC_GCL_FOR_FORWARDING sorts "Saved messages" to the top of the chatlist - * and hides the "Device chat" and contact requests. + * and hides the "Device chat", contact requests and incoming broadcasts. * typically used on forwarding, may be combined with DC_GCL_NO_SPECIALS * to also hide the archive link. * - if the flag DC_GCL_NO_SPECIALS is set, archive link is not added diff --git a/src/chatlist.rs b/src/chatlist.rs index 102d9387e..fb5109578 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -76,7 +76,7 @@ impl Chatlist { /// the pseudo-chat DC_CHAT_ID_ARCHIVED_LINK is added if there are *any* archived /// chats /// - the flag DC_GCL_FOR_FORWARDING sorts "Saved messages" to the top of the chatlist - /// and hides the device-chat and contact requests + /// and hides the device-chat, contact requests and incoming broadcasts. /// typically used on forwarding, may be combined with DC_GCL_NO_SPECIALS /// - if the flag DC_GCL_NO_SPECIALS is set, archive link is not added /// to the list (may be used eg. for selecting chats on forwarding, the flag is @@ -224,8 +224,9 @@ impl Chatlist { let process_rows = |rows: rusqlite::AndThenRows<_>| { rows.filter_map(|row: std::result::Result<(_, _, Params, _), _>| match row { Ok((chat_id, typ, param, msg_id)) => { - if typ == Chattype::Mailinglist - && param.get(Param::ListPost).is_none_or_empty() + if typ == Chattype::InBroadcast + || (typ == Chattype::Mailinglist + && param.get(Param::ListPost).is_none_or_empty()) { None } else { @@ -597,6 +598,41 @@ mod tests { assert_eq!(chats.len(), 1); } + /// Test that DC_CHAT_TYPE_IN_BROADCAST are hidden + /// and DC_CHAT_TYPE_OUT_BROADCAST are shown in chatlist for forwarding. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_broadcast_visiblity_on_forward() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + + let alice_broadcast_a_id = create_broadcast(alice, "Channel Alice".to_string()).await?; + let qr = get_securejoin_qr(alice, Some(alice_broadcast_a_id)) + .await + .unwrap(); + let bob_broadcast_a_id = tcm.exec_securejoin_qr(bob, alice, &qr).await; + let bob_broadcast_b_id = create_broadcast(bob, "Channel Bob".to_string()).await?; + + let chats = Chatlist::try_load(bob, DC_GCL_FOR_FORWARDING, None, None) + .await + .unwrap(); + + assert!( + !chats + .iter() + .any(|(chat_id, _)| chat_id == &bob_broadcast_a_id), + "alice broadcast is not shown in bobs forwarding chatlist" + ); + assert!( + chats + .iter() + .any(|(chat_id, _)| chat_id == &bob_broadcast_b_id), + "bobs own broadcast is shown in his forwarding chatlist" + ); + + Ok(()) + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_search_special_chat_names() { let t = TestContext::new_alice().await;