Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub struct ReceivedMsg {
/// don't assign the message to an encrypted
/// group after looking up key-contacts
/// or vice versa.
#[derive(Debug)]
#[derive(Debug, PartialEq)]
enum ChatAssignment {
/// Trash the message.
Trash,
Expand Down Expand Up @@ -1620,8 +1620,24 @@ async fn do_chat_assignment(
}
}

// automatically unblock chat when the user sends a message
if chat_id_blocked != Blocked::Not {
// Automatically unblock the chat when the user sends a 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 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 {
chat_id.unblock_ex(context, Nosync).await?;
chat_id_blocked = Blocked::Not;
Expand Down Expand Up @@ -3869,7 +3885,7 @@ async fn lookup_key_contact_by_fingerprint(
.sql
.query_row_optional(
"SELECT id FROM contacts
WHERE fingerprint=? AND fingerprint!=''",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a check above

WHERE fingerprint=?",
(fingerprint,),
|row| {
let contact_id: ContactId = row.get(0)?;
Expand Down
Loading