mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Do not reply to messages that can't be decrypted
This commit fixes the test broken in previous commit.
This commit is contained in:
committed by
holger krekel
parent
35566f5ea5
commit
7de23f86b1
40
src/chat.rs
40
src/chat.rs
@@ -422,15 +422,35 @@ impl ChatId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_parent_mime_headers(self, context: &Context) -> Option<(String, String, String)> {
|
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)?));
|
let collect =
|
||||||
self.parent_query(
|
|row: &rusqlite::Row| Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?));
|
||||||
context,
|
let (packed, rfc724_mid, mime_in_reply_to, mime_references): (
|
||||||
"rfc724_mid, mime_in_reply_to, mime_references",
|
String,
|
||||||
collect,
|
String,
|
||||||
)
|
String,
|
||||||
.await
|
String,
|
||||||
.ok()
|
) = self
|
||||||
.flatten()
|
.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> {
|
async fn parent_is_encrypted(self, context: &Context) -> Result<bool, Error> {
|
||||||
@@ -439,7 +459,7 @@ impl ChatId {
|
|||||||
|
|
||||||
if let Some(ref packed) = packed {
|
if let Some(ref packed) = packed {
|
||||||
let param = packed.parse::<Params>()?;
|
let param = packed.parse::<Params>()?;
|
||||||
Ok(param.exists(Param::GuaranteeE2ee))
|
Ok(!param.exists(Param::Error) && param.exists(Param::GuaranteeE2ee))
|
||||||
} else {
|
} else {
|
||||||
// No messages
|
// No messages
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
|||||||
@@ -527,6 +527,7 @@ impl MimeMessage {
|
|||||||
part.typ = Viewtype::Text;
|
part.typ = Viewtype::Text;
|
||||||
part.msg_raw = Some(txt.clone());
|
part.msg_raw = Some(txt.clone());
|
||||||
part.msg = txt;
|
part.msg = txt;
|
||||||
|
part.param.set(Param::Error, "Decryption failed");
|
||||||
|
|
||||||
self.parts.push(part);
|
self.parts.push(part);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user