mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 14:26:30 +03:00
fix: Prefer to encrypt if E2eeEnabled even if peers have EncryptPreference::NoPreference
First of all, chatmail servers normally forbid to send unencrypted mail, so if we know the peer's key, we should encrypt to it. Chatmail setups have `E2eeEnabled=1` by default and this isn't possible to change in UIs, so this change fixes the chatmail case. Additionally, for chatmail, if a peer has `EncryptPreference::Reset`, let's handle it as `EncryptPreference::NoPreference` for the reason above. Still, if `E2eeEnabled` is 0 for a chatmail setup somehow, e.g. the user set it via environment, let's assume that the user knows what they do and ignore `IsChatmail` flag. NB: - If we don't know the peer's key, we should try to send an unencrypted message as before for a chatmail setup. - This change doesn't remove the "majority rule", but now the majority with `EncryptPreference::NoPreference` can't disable encryption if the local preference is `Mutual`. To disable encryption, some peer should have a missing peerstate or, for the non-chatmail case, the majority should have `EncryptPreference::Reset`.
This commit is contained in:
@@ -652,7 +652,9 @@ impl MimeFactory {
|
||||
|
||||
let peerstates = self.peerstates_for_recipients(context).await?;
|
||||
let is_encrypted = !self.should_force_plaintext()
|
||||
&& encrypt_helper.should_encrypt(context, e2ee_guaranteed, &peerstates)?;
|
||||
&& encrypt_helper
|
||||
.should_encrypt(context, e2ee_guaranteed, &peerstates)
|
||||
.await?;
|
||||
let is_securejoin_message = if let Loaded::Message { msg, .. } = &self.loaded {
|
||||
msg.param.get_cmd() == SystemMessage::SecurejoinMessage
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user