fix: Return from dc_get_chatlist(DC_GCL_FOR_FORWARDING) only chats where we can send (#4616)

I.e. exclude from the list the following chats as well:
- Read-only mailing lists.
- Chats we're not a member of.

But as for ProtectionBroken chats, we return them, as that may happen to a verified chat at any
time. It may be confusing if a chat that is normally in the list disappears suddenly. The UI need to
deal with that case anyway.

(cherry picked from commit 83ef25e7de)
This commit is contained in:
iequidoo
2023-08-11 12:35:55 -03:00
committed by iequidoo
parent 47d465e6e4
commit 7c7cd9cc80
3 changed files with 93 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ use crate::chat::{
};
use crate::chat::{get_chat_msgs, ChatItem, ChatVisibility};
use crate::chatlist::Chatlist;
use crate::constants::DC_GCL_NO_SPECIALS;
use crate::constants::{DC_GCL_FOR_FORWARDING, DC_GCL_NO_SPECIALS};
use crate::imap::prefetch_should_download;
use crate::message::Message;
use crate::test_utils::{get_chat_msg, TestContext, TestContextManager};
@@ -793,6 +793,8 @@ async fn test_github_mailing_list() -> Result<()> {
let chats = Chatlist::try_load(&t.ctx, 0, None, None).await?;
assert_eq!(chats.len(), 1);
let chats = Chatlist::try_load(&t.ctx, DC_GCL_FOR_FORWARDING, None, None).await?;
assert_eq!(chats.len(), 0);
let contacts = Contact::get_all(&t.ctx, 0, None).await?;
assert_eq!(contacts.len(), 0); // mailing list recipients and senders do not count as "known contacts"