mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
Only reset status to "" if a text/plain part without signature is received
Otherwise sending a message without plaintext part resets the signature. It is particularly dangerous in multidevice case, because it's easy to accidentally reset the signature on your other device with a non-text message.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
- Show a warning if quota list is empty #4261
|
||||
- Update "accounts.toml" atomically
|
||||
- Don't let blocking be bypassed using groups #4316
|
||||
- Do not reset status on other devices when sending signed reaction messages #3692
|
||||
|
||||
## [1.112.7] - 2023-04-17
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ pub(crate) struct MimeMessage {
|
||||
pub(crate) delivery_report: Option<DeliveryReport>,
|
||||
|
||||
/// Standard USENET signature, if any.
|
||||
///
|
||||
/// `None` means no text part was received, empty string means a text part without a footer is
|
||||
/// received.
|
||||
pub(crate) footer: Option<String>,
|
||||
|
||||
// if this flag is set, the parts/text/etc. are just close to the original mime-message;
|
||||
@@ -1059,6 +1062,7 @@ impl MimeMessage {
|
||||
}
|
||||
};
|
||||
|
||||
let is_plaintext = mime_type == mime::TEXT_PLAIN;
|
||||
let mut dehtml_failed = false;
|
||||
|
||||
let SimplifiedText {
|
||||
@@ -1139,7 +1143,9 @@ impl MimeMessage {
|
||||
self.is_forwarded = true;
|
||||
}
|
||||
|
||||
self.footer = footer;
|
||||
if self.footer.is_none() && is_plaintext {
|
||||
self.footer = Some(footer.unwrap_or_default());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -309,28 +309,25 @@ pub(crate) async fn receive_imf_inner(
|
||||
}
|
||||
}
|
||||
|
||||
// Always update the status, even if there is no footer, to allow removing the status.
|
||||
//
|
||||
// Ignore MDNs though, as they never contain the signature even if user has set it.
|
||||
// Ignore footers from mailinglists as they are often created or modified by the mailinglist software.
|
||||
if mime_parser.mdn_reports.is_empty()
|
||||
&& !mime_parser.is_mailinglist_message()
|
||||
&& is_partial_download.is_none()
|
||||
&& from_id != ContactId::UNDEFINED
|
||||
&& context
|
||||
.update_contacts_timestamp(from_id, Param::StatusTimestamp, sent_timestamp)
|
||||
.await?
|
||||
{
|
||||
if let Err(err) = contact::set_status(
|
||||
context,
|
||||
from_id,
|
||||
mime_parser.footer.clone().unwrap_or_default(),
|
||||
mime_parser.was_encrypted(),
|
||||
mime_parser.has_chat_version(),
|
||||
)
|
||||
.await
|
||||
if let Some(footer) = &mime_parser.footer {
|
||||
if !mime_parser.is_mailinglist_message()
|
||||
&& from_id != ContactId::UNDEFINED
|
||||
&& context
|
||||
.update_contacts_timestamp(from_id, Param::StatusTimestamp, sent_timestamp)
|
||||
.await?
|
||||
{
|
||||
warn!(context, "Cannot update contact status: {err:#}.");
|
||||
if let Err(err) = contact::set_status(
|
||||
context,
|
||||
from_id,
|
||||
footer.to_string(),
|
||||
mime_parser.was_encrypted(),
|
||||
mime_parser.has_chat_version(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
warn!(context, "Cannot update contact status: {err:#}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user