MCPcopy Create free account
hub / github.com/chatmail/core / is_encrypted

Method is_encrypted

src/chat.rs:1680–1713  ·  view source on GitHub ↗

Returns true if the chat is encrypted.

(&self, context: &Context)

Source from the content-addressed store, hash-verified

1678
1679 /// Returns true if the chat is encrypted.
1680 pub async fn is_encrypted(&self, context: &Context) -> Result<bool> {
1681 let is_encrypted = self.is_self_talk()
1682 || match self.typ {
1683 Chattype::Single => {
1684 match context
1685 .sql
1686 .query_row_optional(
1687 "SELECT cc.contact_id, c.fingerprint<>''
1688 FROM chats_contacts cc LEFT JOIN contacts c
1689 ON c.id=cc.contact_id
1690 WHERE cc.chat_id=?
1691 ",
1692 (self.id,),
1693 |row| {
1694 let id: ContactId = row.get(0)?;
1695 let is_key: bool = row.get(1)?;
1696 Ok((id, is_key))
1697 },
1698 )
1699 .await?
1700 {
1701 Some((id, is_key)) => is_key || id == ContactId::DEVICE,
1702 None => true,
1703 }
1704 }
1705 Chattype::Group => {
1706 // Do not encrypt ad-hoc groups.
1707 !self.grpid.is_empty()
1708 }
1709 Chattype::Mailinglist => false,
1710 Chattype::OutBroadcast | Chattype::InBroadcast => true,
1711 };
1712 Ok(is_encrypted)
1713 }
1714
1715 /// Returns true if location streaming is enabled in the chat.
1716 pub fn is_sending_locations(&self) -> bool {

Callers 7

get_encryption_infoMethod · 0.45
get_profile_imageMethod · 0.45
sync_contactsMethod · 0.45
get_for_contactMethod · 0.45
prepare_send_msgFunction · 0.45
add_contact_to_chat_exFunction · 0.45

Calls 4

query_row_optionalMethod · 0.80
is_self_talkMethod · 0.45
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected