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:
link2xt
2022-10-24 23:04:03 +00:00
parent 4aae48b0a1
commit 3c774b02e5
3 changed files with 25 additions and 21 deletions

View File

@@ -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:#}.");
}
}
}