fix: Switch to EncryptionPreference::Mutual on a receipt of encrypted+signed message (#4707)

This commit is contained in:
iequidoo
2023-11-01 23:50:20 -03:00
committed by iequidoo
parent d840a7e6b9
commit 9cd3a7550b
4 changed files with 291 additions and 0 deletions

View File

@@ -376,6 +376,12 @@ impl MimeMessage {
if !encrypted {
signatures.clear();
}
if let Some(peerstate) = &mut decryption_info.peerstate {
if peerstate.prefer_encrypt != EncryptPreference::Mutual && !signatures.is_empty() {
peerstate.prefer_encrypt = EncryptPreference::Mutual;
peerstate.save_to_db(&context.sql).await?;
}
}
// Auto-submitted is also set by holiday-notices so we also check `chat-version`
let is_bot = headers.contains_key("auto-submitted") && headers.contains_key("chat-version");