Skip to content

Commit 53d6a2d

Browse files
committed
api!: remove public APIs to check if the chat is protected
1 parent 4169e0c commit 53d6a2d

File tree

9 files changed

+1
-83
lines changed

9 files changed

+1
-83
lines changed

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,23 +3827,6 @@ int dc_chat_is_device_talk (const dc_chat_t* chat);
38273827
int dc_chat_can_send (const dc_chat_t* chat);
38283828

38293829

3830-
/**
3831-
* Check if a chat is protected.
3832-
*
3833-
* Only verified contacts
3834-
* as determined by dc_contact_is_verified()
3835-
* can be added to protected chats.
3836-
*
3837-
* Protected chats are created using dc_create_group_chat()
3838-
* by setting the 'protect' parameter to 1.
3839-
*
3840-
* @memberof dc_chat_t
3841-
* @param chat The chat object.
3842-
* @return 1=chat protected, 0=chat is not protected.
3843-
*/
3844-
int dc_chat_is_protected (const dc_chat_t* chat);
3845-
3846-
38473830
/**
38483831
* Check if the chat is encrypted.
38493832
*

deltachat-ffi/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,16 +3143,6 @@ pub unsafe extern "C" fn dc_chat_can_send(chat: *mut dc_chat_t) -> libc::c_int {
31433143
.unwrap_or_default() as libc::c_int
31443144
}
31453145

3146-
#[no_mangle]
3147-
pub unsafe extern "C" fn dc_chat_is_protected(chat: *mut dc_chat_t) -> libc::c_int {
3148-
if chat.is_null() {
3149-
eprintln!("ignoring careless call to dc_chat_is_protected()");
3150-
return 0;
3151-
}
3152-
let ffi_chat = &*chat;
3153-
ffi_chat.chat.is_protected() as libc::c_int
3154-
}
3155-
31563146
#[no_mangle]
31573147
pub unsafe extern "C" fn dc_chat_is_encrypted(chat: *mut dc_chat_t) -> libc::c_int {
31583148
if chat.is_null() {

deltachat-jsonrpc/src/api/types/chat.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ pub struct FullChat {
1919
id: u32,
2020
name: String,
2121

22-
/// True if the chat is protected.
23-
///
24-
/// Only verified contacts
25-
/// as determined by [`ContactObject::is_verified`] / `Contact.isVerified`
26-
/// can be added to protected chats.
27-
///
28-
/// Protected chats are created using [`create_group_chat`] / `createGroupChat()`
29-
/// by setting the 'protect' parameter to true.
30-
///
31-
/// [`create_group_chat`]: crate::api::CommandApi::create_group_chat
32-
is_protected: bool,
33-
3422
/// True if the chat is encrypted.
3523
/// This means that all messages in the chat are encrypted,
3624
/// and all contacts in the chat are "key-contacts",
@@ -131,7 +119,6 @@ impl FullChat {
131119
Ok(FullChat {
132120
id: chat_id,
133121
name: chat.name.clone(),
134-
is_protected: chat.is_protected(),
135122
is_encrypted: chat.is_encrypted(context).await?,
136123
profile_image, //BLOBS ?
137124
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
@@ -172,18 +159,6 @@ pub struct BasicChat {
172159
id: u32,
173160
name: String,
174161

175-
/// True if the chat is protected.
176-
///
177-
/// UI should display a green checkmark
178-
/// in the chat title,
179-
/// in the chat profile title and
180-
/// in the chatlist item
181-
/// if chat protection is enabled.
182-
/// UI should also display a green checkmark
183-
/// in the contact profile
184-
/// if 1:1 chat with this contact exists and is protected.
185-
is_protected: bool,
186-
187162
/// True if the chat is encrypted.
188163
/// This means that all messages in the chat are encrypted,
189164
/// and all contacts in the chat are "key-contacts",
@@ -234,7 +209,6 @@ impl BasicChat {
234209
Ok(BasicChat {
235210
id: chat_id,
236211
name: chat.name.clone(),
237-
is_protected: chat.is_protected(),
238212
is_encrypted: chat.is_encrypted(context).await?,
239213
profile_image, //BLOBS ?
240214
archived: chat.get_visibility() == chat::ChatVisibility::Archived,

deltachat-jsonrpc/src/api/types/chat_list.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub enum ChatListItemFetchResult {
3030
summary_status: u32,
3131
/// showing preview if last chat message is image
3232
summary_preview_image: Option<String>,
33-
is_protected: bool,
3433

3534
/// True if the chat is encrypted.
3635
/// This means that all messages in the chat are encrypted,
@@ -161,7 +160,6 @@ pub(crate) async fn get_chat_list_item_by_id(
161160
summary_text2,
162161
summary_status: summary.state.to_u32().expect("impossible"), // idea and a function to transform the constant to strings? or return string enum
163162
summary_preview_image,
164-
is_protected: chat.is_protected(),
165163
is_encrypted: chat.is_encrypted(ctx).await?,
166164
is_group: chat.get_type() == Chattype::Group,
167165
fresh_message_counter,

deltachat-jsonrpc/src/api/types/message.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ impl MessageSearchResult {
579579
chat_color,
580580
chat_type: chat.get_type().to_u32().context("unknown chat type id")?,
581581
chat_profile_image,
582-
is_chat_protected: chat.is_protected(),
583582
is_chat_contact_request: chat.is_contact_request(),
584583
is_chat_archived: chat.get_visibility() == ChatVisibility::Archived,
585584
message: message.get_text(),

deltachat-rpc-client/tests/test_securejoin.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def test_qr_securejoin(acfactory, protect):
6868

6969
logging.info("Alice creates a group")
7070
alice_chat = alice.create_group("Group", protect=protect)
71-
assert alice_chat.get_basic_snapshot().is_protected == protect
7271

7372
logging.info("Bob joins the group")
7473
qr_code = alice_chat.get_qr_code()
@@ -89,7 +88,6 @@ def test_qr_securejoin(acfactory, protect):
8988

9089
snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
9190
assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr"))
92-
assert snapshot.chat.get_basic_snapshot().is_protected == protect
9391

9492
# Test that Bob verified Alice's profile.
9593
bob_contact_alice = bob.create_contact(alice)
@@ -218,7 +216,6 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
218216

219217
logging.info("ac1 creates verified group")
220218
chat = ac1.create_group("Verified group", protect=True)
221-
assert chat.get_basic_snapshot().is_protected
222219

223220
logging.info("ac2 joins verified group")
224221
qr_code = chat.get_qr_code()
@@ -313,7 +310,6 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
313310
while 1:
314311
snapshot = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot()
315312
if snapshot.text == "ac1 says hello":
316-
assert snapshot.chat.get_basic_snapshot().is_protected
317313
break
318314

319315
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):
335331
while 1:
336332
msg = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot()
337333
if msg.text == "hello":
338-
assert msg.chat.get_basic_snapshot().is_protected
339334
break
340335

341336
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):
385380

386381
logging.info("ac1: create verified-group QR, ac2 scans and joins")
387382
chat = ac1.create_group("hello", protect=True)
388-
assert chat.get_basic_snapshot().is_protected
389383
qr_code = chat.get_qr_code()
390384
logging.info("ac2: start QR-code based join-group protocol")
391385
ac2.secure_join(qr_code)
@@ -439,7 +433,6 @@ def test_gossip_verification(acfactory) -> None:
439433

440434
logging.info("Bob creates an Autocrypt group")
441435
bob_group_chat = bob.create_group("Autocrypt Group")
442-
assert not bob_group_chat.get_basic_snapshot().is_protected
443436
bob_group_chat.add_contact(bob_contact_alice)
444437
bob_group_chat.add_contact(bob_contact_carol)
445438
bob_group_chat.send_message(text="Hello Autocrypt group")
@@ -454,7 +447,6 @@ def test_gossip_verification(acfactory) -> None:
454447

455448
logging.info("Bob creates a Securejoin group")
456449
bob_group_chat = bob.create_group("Securejoin Group", protect=True)
457-
assert bob_group_chat.get_basic_snapshot().is_protected
458450
bob_group_chat.add_contact(bob_contact_alice)
459451
bob_group_chat.add_contact(bob_contact_carol)
460452
bob_group_chat.send_message(text="Hello Securejoin group")
@@ -525,7 +517,6 @@ def test_securejoin_after_contact_resetup(acfactory) -> None:
525517
snapshot = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot()
526518
assert snapshot.is_info
527519
ac2_chat = snapshot.chat
528-
assert ac2_chat.get_basic_snapshot().is_protected
529520
assert len(ac2_chat.get_contacts()) == 3
530521

531522
# ac1 is still "not verified" for ac2 due to inconsistent state.
@@ -537,7 +528,6 @@ def test_withdraw_securejoin_qr(acfactory):
537528

538529
logging.info("Alice creates a verified group")
539530
alice_chat = alice.create_group("Verified group", protect=True)
540-
assert alice_chat.get_basic_snapshot().is_protected
541531
logging.info("Bob joins verified group")
542532

543533
qr_code = alice_chat.get_qr_code()
@@ -548,7 +538,6 @@ def test_withdraw_securejoin_qr(acfactory):
548538

549539
snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
550540
assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr"))
551-
assert snapshot.chat.get_basic_snapshot().is_protected
552541
bob_chat.leave()
553542

554543
snapshot = alice.get_message_by_id(alice.wait_for_msgs_changed_event().msg_id).get_snapshot()

python/src/deltachat/chat.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ def can_send(self) -> bool:
142142
"""
143143
return bool(lib.dc_chat_can_send(self._dc_chat))
144144

145-
def is_protected(self) -> bool:
146-
"""return True if this chat is a protected chat.
147-
148-
:returns: True if chat is protected, False otherwise.
149-
"""
150-
return bool(lib.dc_chat_is_protected(self._dc_chat))
151-
152145
def get_name(self) -> Optional[str]:
153146
"""return name of this chat.
154147

python/tests/test_0_complex_or_slow.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def test_qr_verified_group_and_chatting(acfactory, lp):
119119
ac1_addr = ac1.get_self_contact().addr
120120
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
121121
chat1 = ac1.create_group_chat("hello", verified=True)
122-
assert chat1.is_protected()
123122
qr = chat1.get_join_qr()
124123
lp.sec("ac2: start QR-code based join-group protocol")
125124
chat2 = ac2.qr_join_chat(qr)
@@ -142,7 +141,6 @@ def test_qr_verified_group_and_chatting(acfactory, lp):
142141
lp.sec("ac2: read message and check that it's a verified chat")
143142
msg = ac2._evtracker.wait_next_incoming_message()
144143
assert msg.text == "hello"
145-
assert msg.chat.is_protected()
146144
assert msg.is_encrypted()
147145

148146
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):
267265

268266
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
269267
chat = ac1.create_group_chat("hello", verified=True)
270-
assert chat.is_protected()
271268
qr = chat.get_join_qr()
272269
lp.sec("ac2: start QR-code based join-group protocol")
273270
chat2 = ac2.qr_join_chat(qr)
@@ -322,7 +319,6 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp
322319

323320
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
324321
chat = ac1.create_group_chat("hello", verified=True)
325-
assert chat.is_protected()
326322
qr = chat.get_join_qr()
327323
lp.sec("ac2: start QR-code based join-group protocol")
328324
ac2.qr_join_chat(qr)
@@ -336,7 +332,6 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp
336332
assert msg_in.is_system_message()
337333
assert contact.addr == ac1.get_config("addr")
338334
chat2 = msg_in.chat
339-
assert chat2.is_protected()
340335
assert chat2.get_messages()[0].text == "Messages are end-to-end encrypted."
341336
assert open(contact.get_profile_image(), "rb").read() == open(avatar_path, "rb").read()
342337

@@ -377,7 +372,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
377372

378373
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
379374
chat1 = ac1.create_group_chat("hello", verified=True)
380-
assert chat1.is_protected()
381375
qr = chat1.get_join_qr()
382376
lp.sec("ac2: start QR-code based join-group protocol")
383377
chat2 = ac2.qr_join_chat(qr)
@@ -402,7 +396,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
402396
assert ac2_offl_ac1_contact.addr == ac1.get_config("addr")
403397
assert not ac2_offl_ac1_contact.is_verified()
404398
chat2_offl = msg_in.chat
405-
assert not chat2_offl.is_protected()
406399

407400
lp.sec("ac2: sending message re-gossiping Autocrypt keys")
408401
chat2.send_text("hi2")
@@ -423,7 +416,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
423416
assert msg_in.text == "hi2"
424417
assert msg_in.chat == chat2_offl
425418
assert msg_in.get_sender_contact().addr == ac2.get_config("addr")
426-
assert msg_in.chat.is_protected()
427419
assert ac2_offl_ac1_contact.is_verified()
428420

429421

src/chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ impl ChatId {
13991399
}
14001400

14011401
/// Returns true if the chat is protected.
1402-
pub async fn is_protected(self, context: &Context) -> Result<ProtectionStatus> {
1402+
pub(crate) async fn is_protected(self, context: &Context) -> Result<ProtectionStatus> {
14031403
let protection_status = context
14041404
.sql
14051405
.query_get_value("SELECT protected FROM chats WHERE id=?", (self,))

0 commit comments

Comments
 (0)