Do not count mailinglist contacts as 'known'.

This commit is contained in:
Hocuri
2020-04-13 15:23:22 +02:00
parent 7b3e6d185e
commit 51e1826958
3 changed files with 11 additions and 5 deletions

View File

@@ -1105,7 +1105,11 @@ pub fn create_by_msg_id(context: &Context, msg_id: MsgId) -> Result<ChatId, Erro
msg_id: MsgId::new(0),
});
}
Contact::scaleup_origin_by_id(context, msg.from_id, Origin::CreateChat);
// If the message is from a mailing list, the contacts are not counted as "known"
if !chat.is_mailing_list() {
Contact::scaleup_origin_by_id(context, msg.from_id, Origin::CreateChat);
}
Ok(chat.id)
}
@@ -2526,7 +2530,6 @@ pub(crate) fn get_chat_id_by_mailinglistid(
)
}
/// Adds a message to device chat.
///
/// Optional `label` can be provided to ensure that message is added only once.

View File

@@ -1785,19 +1785,22 @@ mod tests {
let chats = Chatlist::try_load(&t.ctx, 0, None, None).unwrap();
assert_eq!(chats.len(), 1);
let chat_id = chat::create_by_msg_id(&t.ctx, chats.get_msg_id(0).unwrap()).unwrap();
let chat = chat::Chat::load_from_db(&t.ctx, chat_id).unwrap();
assert!(chat.is_mailing_list());
assert_eq!(chat.can_send(), false);
assert_eq!(chat.name, "deltachat/deltachat-core-rust");
assert_eq!(chat::get_chat_contacts(&t.ctx, chat_id).len(), 0);
dc_receive_imf(&t.ctx, MAILINGLIST2, "INBOX", 1, false).unwrap();
let chats = Chatlist::try_load(&t.ctx, 0, None, None).unwrap();
assert_eq!(chats.len(), 1);
assert!(Contact::get_all(&t.ctx, 0, None as Option<String>).unwrap().is_empty());
let contacts = Contact::get_all(&t.ctx, 0, None as Option<String>).unwrap();
assert_eq!(contacts.len(), 0); // mailing list recipients and senders do not count as "known contacts"
}
#[test]

View File

@@ -118,7 +118,7 @@ pub enum Param {
/// For MDN-sending job
MsgId = b'I',
MailingList = b't'
MailingList = b't',
}
/// Possible values for `Param::ForcePlaintext`.