Do not reply to messages that can't be decrypted

This commit fixes the test broken in previous commit.
This commit is contained in:
Alexander Krotov
2020-06-08 22:45:51 +03:00
committed by holger krekel
parent 35566f5ea5
commit 7de23f86b1
2 changed files with 31 additions and 10 deletions

View File

@@ -422,15 +422,35 @@ impl ChatId {
}
async fn get_parent_mime_headers(self, context: &Context) -> Option<(String, String, String)> {
let collect = |row: &rusqlite::Row| Ok((row.get(0)?, row.get(1)?, row.get(2)?));
self.parent_query(
context,
"rfc724_mid, mime_in_reply_to, mime_references",
collect,
)
.await
.ok()
.flatten()
let collect =
|row: &rusqlite::Row| Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?));
let (packed, rfc724_mid, mime_in_reply_to, mime_references): (
String,
String,
String,
String,
) = self
.parent_query(
context,
"param, rfc724_mid, mime_in_reply_to, mime_references",
collect,
)
.await
.ok()
.flatten()?;
let param = packed.parse::<Params>().ok()?;
if param.exists(Param::Error) {
// Do not reply to error messages.
//
// An error message could be a group chat message that we failed to decrypt and
// assigned to 1:1 chat. A reply to it will show up as a reply to group message
// on the other side. To avoid such situations, it is better not to reply to
// error messages at all.
None
} else {
Some((rfc724_mid, mime_in_reply_to, mime_references))
}
}
async fn parent_is_encrypted(self, context: &Context) -> Result<bool, Error> {
@@ -439,7 +459,7 @@ impl ChatId {
if let Some(ref packed) = packed {
let param = packed.parse::<Params>()?;
Ok(param.exists(Param::GuaranteeE2ee))
Ok(!param.exists(Param::Error) && param.exists(Param::GuaranteeE2ee))
} else {
// No messages
Ok(false)

View File

@@ -527,6 +527,7 @@ impl MimeMessage {
part.typ = Viewtype::Text;
part.msg_raw = Some(txt.clone());
part.msg = txt;
part.param.set(Param::Error, "Decryption failed");
self.parts.push(part);