mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: is_encrypted() should be true for Saved Messages chat
Otherwise UIs don't allow to edit messages sent to self.
This was likely broken in b417ba86bc
This commit is contained in:
51
src/chat.rs
51
src/chat.rs
@@ -1643,36 +1643,37 @@ impl Chat {
|
|||||||
|
|
||||||
/// Returns true if the chat is encrypted.
|
/// Returns true if the chat is encrypted.
|
||||||
pub async fn is_encrypted(&self, context: &Context) -> Result<bool> {
|
pub async fn is_encrypted(&self, context: &Context) -> Result<bool> {
|
||||||
let is_encrypted = match self.typ {
|
let is_encrypted = self.is_self_talk()
|
||||||
Chattype::Single => {
|
|| match self.typ {
|
||||||
match context
|
Chattype::Single => {
|
||||||
.sql
|
match context
|
||||||
.query_row_optional(
|
.sql
|
||||||
"SELECT cc.contact_id, c.fingerprint<>''
|
.query_row_optional(
|
||||||
|
"SELECT cc.contact_id, c.fingerprint<>''
|
||||||
FROM chats_contacts cc LEFT JOIN contacts c
|
FROM chats_contacts cc LEFT JOIN contacts c
|
||||||
ON c.id=cc.contact_id
|
ON c.id=cc.contact_id
|
||||||
WHERE cc.chat_id=?
|
WHERE cc.chat_id=?
|
||||||
",
|
",
|
||||||
(self.id,),
|
(self.id,),
|
||||||
|row| {
|
|row| {
|
||||||
let id: ContactId = row.get(0)?;
|
let id: ContactId = row.get(0)?;
|
||||||
let is_key: bool = row.get(1)?;
|
let is_key: bool = row.get(1)?;
|
||||||
Ok((id, is_key))
|
Ok((id, is_key))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
{
|
{
|
||||||
Some((id, is_key)) => is_key || id == ContactId::DEVICE,
|
Some((id, is_key)) => is_key || id == ContactId::DEVICE,
|
||||||
None => true,
|
None => true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Chattype::Group => {
|
||||||
Chattype::Group => {
|
// Do not encrypt ad-hoc groups.
|
||||||
// Do not encrypt ad-hoc groups.
|
!self.grpid.is_empty()
|
||||||
!self.grpid.is_empty()
|
}
|
||||||
}
|
Chattype::Mailinglist => false,
|
||||||
Chattype::Mailinglist => false,
|
Chattype::OutBroadcast | Chattype::InBroadcast => true,
|
||||||
Chattype::OutBroadcast | Chattype::InBroadcast => true,
|
};
|
||||||
};
|
|
||||||
Ok(is_encrypted)
|
Ok(is_encrypted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -801,6 +801,7 @@ async fn test_self_talk() -> Result<()> {
|
|||||||
let chat = &t.get_self_chat().await;
|
let chat = &t.get_self_chat().await;
|
||||||
assert!(!chat.id.is_special());
|
assert!(!chat.id.is_special());
|
||||||
assert!(chat.is_self_talk());
|
assert!(chat.is_self_talk());
|
||||||
|
assert!(chat.is_encrypted(&t).await?);
|
||||||
assert!(chat.visibility == ChatVisibility::Normal);
|
assert!(chat.visibility == ChatVisibility::Normal);
|
||||||
assert!(!chat.is_device_talk());
|
assert!(!chat.is_device_talk());
|
||||||
assert!(chat.can_send(&t).await?);
|
assert!(chat.can_send(&t).await?);
|
||||||
|
|||||||
Reference in New Issue
Block a user