mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +03:00
fix: Don't unblock chat on possibly wrongly assigned outgoing encrypted 1:1 message
For encrypted 1:1 messages we don't check the recipient fingerprint currently, so check that we don't have multiple key-contacts with the given recipient address.
This commit is contained in:
@@ -85,7 +85,7 @@ pub struct ReceivedMsg {
|
|||||||
/// don't assign the message to an encrypted
|
/// don't assign the message to an encrypted
|
||||||
/// group after looking up key-contacts
|
/// group after looking up key-contacts
|
||||||
/// or vice versa.
|
/// or vice versa.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
enum ChatAssignment {
|
enum ChatAssignment {
|
||||||
/// Trash the message.
|
/// Trash the message.
|
||||||
Trash,
|
Trash,
|
||||||
@@ -1620,8 +1620,24 @@ async fn do_chat_assignment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// automatically unblock chat when the user sends a message
|
// Automatically unblock the chat when the user sends a message. For encrypted 1:1 messages
|
||||||
if chat_id_blocked != Blocked::Not {
|
// we don't check the recipient fingerprint currently, so check that we don't have multiple
|
||||||
|
// key-contacts with the given address.
|
||||||
|
if chat_id_blocked != Blocked::Not
|
||||||
|
&& (!mime_parser.was_encrypted() || chat_assignment != ChatAssignment::OneOneChat || {
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.count(
|
||||||
|
"SELECT COUNT(*) FROM contacts
|
||||||
|
WHERE contacts.addr=(SELECT addr FROM contacts WHERE id=?)
|
||||||
|
AND fingerprint<>''
|
||||||
|
",
|
||||||
|
(to_id,),
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
== 1
|
||||||
|
})
|
||||||
|
{
|
||||||
if let Some(chat_id) = chat_id {
|
if let Some(chat_id) = chat_id {
|
||||||
chat_id.unblock_ex(context, Nosync).await?;
|
chat_id.unblock_ex(context, Nosync).await?;
|
||||||
chat_id_blocked = Blocked::Not;
|
chat_id_blocked = Blocked::Not;
|
||||||
@@ -3869,7 +3885,7 @@ async fn lookup_key_contact_by_fingerprint(
|
|||||||
.sql
|
.sql
|
||||||
.query_row_optional(
|
.query_row_optional(
|
||||||
"SELECT id FROM contacts
|
"SELECT id FROM contacts
|
||||||
WHERE fingerprint=? AND fingerprint!=''",
|
WHERE fingerprint=?",
|
||||||
(fingerprint,),
|
(fingerprint,),
|
||||||
|row| {
|
|row| {
|
||||||
let contact_id: ContactId = row.get(0)?;
|
let contact_id: ContactId = row.get(0)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user