Returns true if the chat is encrypted.
(&self, context: &Context)
| 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 { |
no test coverage detected