diff --git a/deltachat-jsonrpc/src/api/types/chat.rs b/deltachat-jsonrpc/src/api/types/chat.rs index 86f78abee..6b5e69304 100644 --- a/deltachat-jsonrpc/src/api/types/chat.rs +++ b/deltachat-jsonrpc/src/api/types/chat.rs @@ -19,18 +19,6 @@ pub struct FullChat { id: u32, name: String, - /// True if the chat is protected. - /// - /// Only verified contacts - /// as determined by [`ContactObject::is_verified`] / `Contact.isVerified` - /// can be added to protected chats. - /// - /// Protected chats are created using [`create_group_chat`] / `createGroupChat()` - /// by setting the 'protect' parameter to true. - /// - /// [`create_group_chat`]: crate::api::CommandApi::create_group_chat - is_protected: bool, - /// True if the chat is encrypted. /// This means that all messages in the chat are encrypted, /// and all contacts in the chat are "key-contacts", @@ -131,7 +119,6 @@ impl FullChat { Ok(FullChat { id: chat_id, name: chat.name.clone(), - is_protected: chat.is_protected(), is_encrypted: chat.is_encrypted(context).await?, profile_image, //BLOBS ? archived: chat.get_visibility() == chat::ChatVisibility::Archived, @@ -172,18 +159,6 @@ pub struct BasicChat { id: u32, name: String, - /// True if the chat is protected. - /// - /// UI should display a green checkmark - /// in the chat title, - /// in the chat profile title and - /// in the chatlist item - /// if chat protection is enabled. - /// UI should also display a green checkmark - /// in the contact profile - /// if 1:1 chat with this contact exists and is protected. - is_protected: bool, - /// True if the chat is encrypted. /// This means that all messages in the chat are encrypted, /// and all contacts in the chat are "key-contacts", @@ -234,7 +209,6 @@ impl BasicChat { Ok(BasicChat { id: chat_id, name: chat.name.clone(), - is_protected: chat.is_protected(), is_encrypted: chat.is_encrypted(context).await?, profile_image, //BLOBS ? archived: chat.get_visibility() == chat::ChatVisibility::Archived, diff --git a/deltachat-jsonrpc/src/api/types/chat_list.rs b/deltachat-jsonrpc/src/api/types/chat_list.rs index b5d31a791..47e72524c 100644 --- a/deltachat-jsonrpc/src/api/types/chat_list.rs +++ b/deltachat-jsonrpc/src/api/types/chat_list.rs @@ -30,7 +30,6 @@ pub enum ChatListItemFetchResult { summary_status: u32, /// showing preview if last chat message is image summary_preview_image: Option, - is_protected: bool, /// True if the chat is encrypted. /// This means that all messages in the chat are encrypted, @@ -161,7 +160,6 @@ pub(crate) async fn get_chat_list_item_by_id( summary_text2, summary_status: summary.state.to_u32().expect("impossible"), // idea and a function to transform the constant to strings? or return string enum summary_preview_image, - is_protected: chat.is_protected(), is_encrypted: chat.is_encrypted(ctx).await?, is_group: chat.get_type() == Chattype::Group, fresh_message_counter, diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index fd47c534d..b2832db94 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -532,7 +532,6 @@ pub struct MessageSearchResult { chat_color: String, chat_name: String, chat_type: u32, - is_chat_protected: bool, is_chat_contact_request: bool, is_chat_archived: bool, message: String, @@ -572,7 +571,6 @@ impl MessageSearchResult { chat_color, chat_type: chat.get_type().to_u32().context("unknown chat type id")?, chat_profile_image, - is_chat_protected: chat.is_protected(), is_chat_contact_request: chat.is_contact_request(), is_chat_archived: chat.get_visibility() == ChatVisibility::Archived, message: message.get_text(), diff --git a/deltachat-rpc-client/tests/test_securejoin.py b/deltachat-rpc-client/tests/test_securejoin.py index 75b565253..26f7361c0 100644 --- a/deltachat-rpc-client/tests/test_securejoin.py +++ b/deltachat-rpc-client/tests/test_securejoin.py @@ -68,7 +68,6 @@ def test_qr_securejoin(acfactory, protect): logging.info("Alice creates a group") alice_chat = alice.create_group("Group", protect=protect) - assert alice_chat.get_basic_snapshot().is_protected == protect logging.info("Bob joins the group") qr_code = alice_chat.get_qr_code() @@ -89,7 +88,6 @@ def test_qr_securejoin(acfactory, protect): snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot() assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr")) - assert snapshot.chat.get_basic_snapshot().is_protected == protect # Test that Bob verified Alice's profile. bob_contact_alice = bob.create_contact(alice) @@ -218,7 +216,6 @@ def test_verified_group_member_added_recovery(acfactory) -> None: logging.info("ac1 creates verified group") chat = ac1.create_group("Verified group", protect=True) - assert chat.get_basic_snapshot().is_protected logging.info("ac2 joins verified group") qr_code = chat.get_qr_code() @@ -313,7 +310,6 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory): while 1: snapshot = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot() if snapshot.text == "ac1 says hello": - assert snapshot.chat.get_basic_snapshot().is_protected break logging.info("ac1: let ac2 join again but shutoff ac1 in the middle of securejoin") @@ -335,7 +331,6 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory): while 1: msg = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot() if msg.text == "hello": - assert msg.chat.get_basic_snapshot().is_protected break logging.info("ac3: create a join-code for group VG and let ac4 join, check that ac2 got it") @@ -385,7 +380,6 @@ def test_aeap_flow_verified(acfactory): logging.info("ac1: create verified-group QR, ac2 scans and joins") chat = ac1.create_group("hello", protect=True) - assert chat.get_basic_snapshot().is_protected qr_code = chat.get_qr_code() logging.info("ac2: start QR-code based join-group protocol") ac2.secure_join(qr_code) @@ -439,7 +433,6 @@ def test_gossip_verification(acfactory) -> None: logging.info("Bob creates an Autocrypt group") bob_group_chat = bob.create_group("Autocrypt Group") - assert not bob_group_chat.get_basic_snapshot().is_protected bob_group_chat.add_contact(bob_contact_alice) bob_group_chat.add_contact(bob_contact_carol) bob_group_chat.send_message(text="Hello Autocrypt group") @@ -454,7 +447,6 @@ def test_gossip_verification(acfactory) -> None: logging.info("Bob creates a Securejoin group") bob_group_chat = bob.create_group("Securejoin Group", protect=True) - assert bob_group_chat.get_basic_snapshot().is_protected bob_group_chat.add_contact(bob_contact_alice) bob_group_chat.add_contact(bob_contact_carol) bob_group_chat.send_message(text="Hello Securejoin group") @@ -525,7 +517,6 @@ def test_securejoin_after_contact_resetup(acfactory) -> None: snapshot = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot() assert snapshot.is_info ac2_chat = snapshot.chat - assert ac2_chat.get_basic_snapshot().is_protected assert len(ac2_chat.get_contacts()) == 3 # ac1 is still "not verified" for ac2 due to inconsistent state. @@ -537,7 +528,6 @@ def test_withdraw_securejoin_qr(acfactory): logging.info("Alice creates a verified group") alice_chat = alice.create_group("Verified group", protect=True) - assert alice_chat.get_basic_snapshot().is_protected logging.info("Bob joins verified group") qr_code = alice_chat.get_qr_code() @@ -548,7 +538,6 @@ def test_withdraw_securejoin_qr(acfactory): snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot() assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr")) - assert snapshot.chat.get_basic_snapshot().is_protected bob_chat.leave() snapshot = alice.get_message_by_id(alice.wait_for_msgs_changed_event().msg_id).get_snapshot() diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index edc2d5ba7..a11bc8074 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -142,13 +142,6 @@ class Chat: """ return bool(lib.dc_chat_can_send(self._dc_chat)) - def is_protected(self) -> bool: - """return True if this chat is a protected chat. - - :returns: True if chat is protected, False otherwise. - """ - return bool(lib.dc_chat_is_protected(self._dc_chat)) - def get_name(self) -> Optional[str]: """return name of this chat. diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index d92dbcacc..be198f8a2 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -119,7 +119,6 @@ def test_qr_verified_group_and_chatting(acfactory, lp): ac1_addr = ac1.get_self_contact().addr lp.sec("ac1: create verified-group QR, ac2 scans and joins") chat1 = ac1.create_group_chat("hello", verified=True) - assert chat1.is_protected() qr = chat1.get_join_qr() lp.sec("ac2: start QR-code based join-group protocol") chat2 = ac2.qr_join_chat(qr) @@ -142,7 +141,6 @@ def test_qr_verified_group_and_chatting(acfactory, lp): lp.sec("ac2: read message and check that it's a verified chat") msg = ac2._evtracker.wait_next_incoming_message() assert msg.text == "hello" - assert msg.chat.is_protected() assert msg.is_encrypted() lp.sec("ac2: Check that ac2 verified ac1") @@ -267,7 +265,6 @@ def test_see_new_verified_member_after_going_online(acfactory, tmp_path, lp): lp.sec("ac1: create verified-group QR, ac2 scans and joins") chat = ac1.create_group_chat("hello", verified=True) - assert chat.is_protected() qr = chat.get_join_qr() lp.sec("ac2: start QR-code based join-group protocol") chat2 = ac2.qr_join_chat(qr) @@ -322,7 +319,6 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp lp.sec("ac1: create verified-group QR, ac2 scans and joins") chat = ac1.create_group_chat("hello", verified=True) - assert chat.is_protected() qr = chat.get_join_qr() lp.sec("ac2: start QR-code based join-group protocol") ac2.qr_join_chat(qr) @@ -336,7 +332,6 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp assert msg_in.is_system_message() assert contact.addr == ac1.get_config("addr") chat2 = msg_in.chat - assert chat2.is_protected() assert chat2.get_messages()[0].text == "Messages are end-to-end encrypted." assert open(contact.get_profile_image(), "rb").read() == open(avatar_path, "rb").read() @@ -377,7 +372,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp): lp.sec("ac1: create verified-group QR, ac2 scans and joins") chat1 = ac1.create_group_chat("hello", verified=True) - assert chat1.is_protected() qr = chat1.get_join_qr() lp.sec("ac2: start QR-code based join-group protocol") chat2 = ac2.qr_join_chat(qr) @@ -402,7 +396,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp): assert ac2_offl_ac1_contact.addr == ac1.get_config("addr") assert not ac2_offl_ac1_contact.is_verified() chat2_offl = msg_in.chat - assert not chat2_offl.is_protected() lp.sec("ac2: sending message re-gossiping Autocrypt keys") chat2.send_text("hi2") @@ -423,7 +416,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp): assert msg_in.text == "hi2" assert msg_in.chat == chat2_offl assert msg_in.get_sender_contact().addr == ac2.get_config("addr") - assert msg_in.chat.is_protected() assert ac2_offl_ac1_contact.is_verified() diff --git a/src/chat.rs b/src/chat.rs index 796eaf32d..33569244e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1397,7 +1397,7 @@ impl ChatId { } /// Returns true if the chat is protected. - pub async fn is_protected(self, context: &Context) -> Result { + pub(crate) async fn is_protected(self, context: &Context) -> Result { let protection_status = context .sql .query_get_value("SELECT protected FROM chats WHERE id=?", (self,))