fixup: download legacy Secure-Join messages even if encryption is enforced

This commit is contained in:
link2xt
2026-05-15 18:43:48 +02:00
parent 79b41239ab
commit 0643cf0cb1
2 changed files with 13 additions and 7 deletions

View File

@@ -1994,12 +1994,15 @@ pub(crate) async fn prefetch_should_download(
// prevent_rename=true as this might be a mailing list message and in this case it would be bad if we rename the contact.
// (prevent_rename is the last argument of from_field_to_contact_id())
let is_encrypted = if let Some(content_type) = headers.get_header_value(HeaderDef::ContentType)
{
mailparse::parse_content_type(&content_type).mimetype == "multipart/encrypted"
} else {
false
};
// New SecureJoin is fully encrypted,
// but for compatibility we still download legacy `Secure-Join: vc-request` messages.
let is_legacy_securejoin = headers.get_header_value(HeaderDef::SecureJoin).is_some();
let is_encrypted = headers
.get_header_value(HeaderDef::ContentType)
.is_some_and(|content_type| {
mailparse::parse_content_type(&content_type).mimetype == "multipart/encrypted"
});
if flags.any(|f| f == Flag::Draft) {
info!(context, "Ignoring draft message");
@@ -2008,7 +2011,9 @@ pub(crate) async fn prefetch_should_download(
let should_download = maybe_ndn
|| (!blocked_contact
&& (is_encrypted || !context.get_config_bool(Config::ForceEncryption).await?));
&& (is_legacy_securejoin
|| is_encrypted
|| !context.get_config_bool(Config::ForceEncryption).await?));
Ok(should_download)
}

View File

@@ -22,6 +22,7 @@ const PREFETCH_FLAGS: &str = "(UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (\
X-MICROSOFT-ORIGINAL-MESSAGE-ID \
FROM \
CONTENT-TYPE \
SECURE-JOIN \
CHAT-VERSION \
CHAT-IS-POST-MESSAGE \
AUTOCRYPT-SETUP-MESSAGE\