mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: MimeFactory::verified: Return true for self-chat
For purposes of building a message it's better to consider the self-chat as verified. Particularly, this removes unencrypted name from the "From" header.
This commit is contained in:
@@ -299,19 +299,12 @@ impl MimeFactory {
|
|||||||
fn verified(&self) -> bool {
|
fn verified(&self) -> bool {
|
||||||
match &self.loaded {
|
match &self.loaded {
|
||||||
Loaded::Message { chat, msg } => {
|
Loaded::Message { chat, msg } => {
|
||||||
if chat.is_protected() {
|
chat.is_self_talk() ||
|
||||||
if msg.get_info_type() == SystemMessage::SecurejoinMessage {
|
// Securejoin messages are supposed to verify a key.
|
||||||
// Securejoin messages are supposed to verify a key.
|
// In order to do this, it is necessary that they can be sent
|
||||||
// In order to do this, it is necessary that they can be sent
|
// to a key that is not yet verified.
|
||||||
// to a key that is not yet verified.
|
// This has to work independently of whether the chat is protected right now.
|
||||||
// This has to work independently of whether the chat is protected right now.
|
chat.is_protected() && msg.get_info_type() != SystemMessage::SecurejoinMessage
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loaded::Mdn { .. } => false,
|
Loaded::Mdn { .. } => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2094,6 +2094,18 @@ Message content",
|
|||||||
assert_ne!(msg.chat_id, t.get_self_chat().await.id);
|
assert_ne!(msg.chat_id, t.get_self_chat().await.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_no_unencrypted_name_in_self_chat() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
bob.set_config(Config::Displayname, Some("Bob Smith"))
|
||||||
|
.await?;
|
||||||
|
let chat_id = bob.get_self_chat().await.id;
|
||||||
|
let msg = bob.send_text(chat_id, "Happy birthday to me").await;
|
||||||
|
assert_eq!(msg.payload.contains("Bob Smith"), false);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_outgoing_classic_mail_creates_chat() {
|
async fn test_outgoing_classic_mail_creates_chat() {
|
||||||
let alice = TestContext::new_alice().await;
|
let alice = TestContext::new_alice().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user