File tree Expand file tree Collapse file tree 2 files changed +27
-25
lines changed Expand file tree Collapse file tree 2 files changed +27
-25
lines changed Original file line number Diff line number Diff line change @@ -1643,36 +1643,37 @@ impl Chat {
16431643
16441644 /// Returns true if the chat is encrypted.
16451645 pub async fn is_encrypted ( & self , context : & Context ) -> Result < bool > {
1646- let is_encrypted = match self . typ {
1647- Chattype :: Single => {
1648- match context
1649- . sql
1650- . query_row_optional (
1651- "SELECT cc.contact_id, c.fingerprint<>''
1646+ let is_encrypted = self . is_self_talk ( )
1647+ || match self . typ {
1648+ Chattype :: Single => {
1649+ match context
1650+ . sql
1651+ . query_row_optional (
1652+ "SELECT cc.contact_id, c.fingerprint<>''
16521653 FROM chats_contacts cc LEFT JOIN contacts c
16531654 ON c.id=cc.contact_id
16541655 WHERE cc.chat_id=?
16551656 " ,
1656- ( self . id , ) ,
1657- |row| {
1658- let id: ContactId = row. get ( 0 ) ?;
1659- let is_key: bool = row. get ( 1 ) ?;
1660- Ok ( ( id, is_key) )
1661- } ,
1662- )
1663- . await ?
1664- {
1665- Some ( ( id, is_key) ) => is_key || id == ContactId :: DEVICE ,
1666- None => true ,
1657+ ( self . id , ) ,
1658+ |row| {
1659+ let id: ContactId = row. get ( 0 ) ?;
1660+ let is_key: bool = row. get ( 1 ) ?;
1661+ Ok ( ( id, is_key) )
1662+ } ,
1663+ )
1664+ . await ?
1665+ {
1666+ Some ( ( id, is_key) ) => is_key || id == ContactId :: DEVICE ,
1667+ None => true ,
1668+ }
16671669 }
1668- }
1669- Chattype :: Group => {
1670- // Do not encrypt ad-hoc groups.
1671- !self . grpid . is_empty ( )
1672- }
1673- Chattype :: Mailinglist => false ,
1674- Chattype :: OutBroadcast | Chattype :: InBroadcast => true ,
1675- } ;
1670+ Chattype :: Group => {
1671+ // Do not encrypt ad-hoc groups.
1672+ !self . grpid . is_empty ( )
1673+ }
1674+ Chattype :: Mailinglist => false ,
1675+ Chattype :: OutBroadcast | Chattype :: InBroadcast => true ,
1676+ } ;
16761677 Ok ( is_encrypted)
16771678 }
16781679
Original file line number Diff line number Diff line change @@ -801,6 +801,7 @@ async fn test_self_talk() -> Result<()> {
801801 let chat = & t. get_self_chat ( ) . await ;
802802 assert ! ( !chat. id. is_special( ) ) ;
803803 assert ! ( chat. is_self_talk( ) ) ;
804+ assert ! ( chat. is_encrypted( & t) . await ?) ;
804805 assert ! ( chat. visibility == ChatVisibility :: Normal ) ;
805806 assert ! ( !chat. is_device_talk( ) ) ;
806807 assert ! ( chat. can_send( & t) . await ?) ;
You can’t perform that action at this time.
0 commit comments