Skip to content

Commit 5b31b5d

Browse files
committed
api!: remove APIs to create protected chats
Create unprotected group in test_create_protected_grp_multidev The test is renamed accordingly. SystemMessage::ChatE2ee is added in encrypted groups regardless of whether they are protected or not. Previously new encrypted unprotected groups had no message saying that messages are end-to-end encrypted at all.
1 parent 921633c commit 5b31b5d

37 files changed

+309
-933
lines changed

deltachat-ffi/deltachat.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,15 +1696,12 @@ dc_chat_t* dc_get_chat (dc_context_t* context, uint32_t ch
16961696
*
16971697
* @memberof dc_context_t
16981698
* @param context The context object.
1699-
* @param protect If set to 1 the function creates group with protection initially enabled.
1700-
* Only verified members are allowed in these groups
1701-
* and end-to-end-encryption is always enabled.
17021699
* @param name The name of the group chat to create.
17031700
* The name may be changed later using dc_set_chat_name().
17041701
* To find out the name of a group later, see dc_chat_get_name()
17051702
* @return The chat ID of the new group chat, 0 on errors.
17061703
*/
1707-
uint32_t dc_create_group_chat (dc_context_t* context, int protect, const char* name);
1704+
uint32_t dc_create_group_chat (dc_context_t* context, const char* name);
17081705

17091706

17101707
/**

deltachat-ffi/src/lib.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::sync::{Arc, LazyLock};
2222
use std::time::{Duration, SystemTime};
2323

2424
use anyhow::Context as _;
25-
use deltachat::chat::{ChatId, ChatVisibility, MessageListOptions, MuteDuration, ProtectionStatus};
25+
use deltachat::chat::{ChatId, ChatVisibility, MessageListOptions, MuteDuration};
2626
use deltachat::constants::DC_MSG_ID_LAST_SPECIAL;
2727
use deltachat::contact::{Contact, ContactId, Origin};
2828
use deltachat::context::{Context, ContextBuilder};
@@ -1659,30 +1659,19 @@ pub unsafe extern "C" fn dc_get_chat(context: *mut dc_context_t, chat_id: u32) -
16591659
#[no_mangle]
16601660
pub unsafe extern "C" fn dc_create_group_chat(
16611661
context: *mut dc_context_t,
1662-
protect: libc::c_int,
16631662
name: *const libc::c_char,
16641663
) -> u32 {
16651664
if context.is_null() || name.is_null() {
16661665
eprintln!("ignoring careless call to dc_create_group_chat()");
16671666
return 0;
16681667
}
16691668
let ctx = &*context;
1670-
let Some(protect) = ProtectionStatus::from_i32(protect)
1671-
.context("Bad protect-value for dc_create_group_chat()")
1672-
.log_err(ctx)
1673-
.ok()
1674-
else {
1675-
return 0;
1676-
};
16771669

1678-
block_on(async move {
1679-
chat::create_group_chat(ctx, protect, &to_string_lossy(name))
1680-
.await
1681-
.context("Failed to create group chat")
1682-
.log_err(ctx)
1683-
.map(|id| id.to_u32())
1684-
.unwrap_or(0)
1685-
})
1670+
block_on(chat::create_group_chat(ctx, &to_string_lossy(name)))
1671+
.context("Failed to create group chat")
1672+
.log_err(ctx)
1673+
.map(|id| id.to_u32())
1674+
.unwrap_or(0)
16861675
}
16871676

16881677
#[no_mangle]

deltachat-jsonrpc/src/api.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use deltachat::blob::BlobObject;
1111
use deltachat::chat::{
1212
self, add_contact_to_chat, forward_msgs, get_chat_media, get_chat_msgs, get_chat_msgs_ex,
1313
marknoticed_chat, remove_contact_from_chat, Chat, ChatId, ChatItem, MessageListOptions,
14-
ProtectionStatus,
1514
};
1615
use deltachat::chatlist::Chatlist;
1716
use deltachat::config::Config;
@@ -968,16 +967,9 @@ impl CommandApi {
968967
///
969968
/// To check, if a chat is still unpromoted, you can look at the `is_unpromoted` property of `BasicChat` or `FullChat`.
970969
/// This may be useful if you want to show some help for just created groups.
971-
///
972-
/// @param protect If set to 1 the function creates group with protection initially enabled.
973-
/// Only verified members are allowed in these groups
974-
async fn create_group_chat(&self, account_id: u32, name: String, protect: bool) -> Result<u32> {
970+
async fn create_group_chat(&self, account_id: u32, name: String) -> Result<u32> {
975971
let ctx = self.get_context(account_id).await?;
976-
let protect = match protect {
977-
true => ProtectionStatus::Protected,
978-
false => ProtectionStatus::Unprotected,
979-
};
980-
chat::create_group_ex(&ctx, Some(protect), &name)
972+
chat::create_group_chat(&ctx, &name)
981973
.await
982974
.map(|id| id.to_u32())
983975
}
@@ -988,7 +980,7 @@ impl CommandApi {
988980
/// address-contacts.
989981
async fn create_group_chat_unencrypted(&self, account_id: u32, name: String) -> Result<u32> {
990982
let ctx = self.get_context(account_id).await?;
991-
chat::create_group_ex(&ctx, None, &name)
983+
chat::create_group_chat_unencrypted(&ctx, &name)
992984
.await
993985
.map(|id| id.to_u32())
994986
}

deltachat-repl/src/cmdline.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::str::FromStr;
66
use std::time::Duration;
77

88
use anyhow::{bail, ensure, Result};
9-
use deltachat::chat::{
10-
self, Chat, ChatId, ChatItem, ChatVisibility, MuteDuration, ProtectionStatus,
11-
};
9+
use deltachat::chat::{self, Chat, ChatId, ChatItem, ChatVisibility, MuteDuration};
1210
use deltachat::chatlist::*;
1311
use deltachat::constants::*;
1412
use deltachat::contact::*;
@@ -353,7 +351,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
353351
createchat <contact-id>\n\
354352
creategroup <name>\n\
355353
createbroadcast <name>\n\
356-
createprotected <name>\n\
357354
addmember <contact-id>\n\
358355
removemember <contact-id>\n\
359356
groupname <name>\n\
@@ -746,8 +743,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
746743
}
747744
"creategroup" => {
748745
ensure!(!arg1.is_empty(), "Argument <name> missing.");
749-
let chat_id =
750-
chat::create_group_chat(&context, ProtectionStatus::Unprotected, arg1).await?;
746+
let chat_id = chat::create_group_chat(&context, arg1).await?;
751747

752748
println!("Group#{chat_id} created successfully.");
753749
}
@@ -757,13 +753,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
757753

758754
println!("Broadcast#{chat_id} created successfully.");
759755
}
760-
"createprotected" => {
761-
ensure!(!arg1.is_empty(), "Argument <name> missing.");
762-
let chat_id =
763-
chat::create_group_chat(&context, ProtectionStatus::Protected, arg1).await?;
764-
765-
println!("Group#{chat_id} created and protected successfully.");
766-
}
767756
"addmember" => {
768757
ensure!(sel_chat.is_some(), "No chat selected");
769758
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");

deltachat-rpc-client/src/deltachat_rpc_client/account.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def get_chatlist(
299299
chats.append(AttrDict(item))
300300
return chats
301301

302-
def create_group(self, name: str, protect: bool = False) -> Chat:
302+
def create_group(self, name: str) -> Chat:
303303
"""Create a new group chat.
304304
305305
After creation,
@@ -316,12 +316,8 @@ def create_group(self, name: str, protect: bool = False) -> Chat:
316316
To check, if a chat is still unpromoted, you can look at the `is_unpromoted` property of a chat
317317
(see `get_full_snapshot()` / `get_basic_snapshot()`).
318318
This may be useful if you want to show some help for just created groups.
319-
320-
:param protect: If set to 1 the function creates group with protection initially enabled.
321-
Only verified members are allowed in these groups
322-
and end-to-end-encryption is always enabled.
323319
"""
324-
return Chat(self, self._rpc.create_group_chat(self.id, name, protect))
320+
return Chat(self, self._rpc.create_group_chat(self.id, name))
325321

326322
def create_broadcast(self, name: str) -> Chat:
327323
"""Create a new **broadcast channel**

deltachat-rpc-client/tests/test_securejoin.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@ def test_qr_setup_contact_svg(acfactory) -> None:
5858
assert "Alice" in svg
5959

6060

61-
@pytest.mark.parametrize("protect", [True, False])
62-
def test_qr_securejoin(acfactory, protect):
61+
def test_qr_securejoin(acfactory):
6362
alice, bob, fiona = acfactory.get_online_accounts(3)
6463

6564
# Setup second device for Alice
6665
# to test observing securejoin protocol.
6766
alice2 = alice.clone()
6867

6968
logging.info("Alice creates a group")
70-
alice_chat = alice.create_group("Group", protect=protect)
69+
alice_chat = alice.create_group("Group")
7170

7271
logging.info("Bob joins the group")
7372
qr_code = alice_chat.get_qr_code()
@@ -123,8 +122,8 @@ def test_qr_securejoin_contact_request(acfactory) -> None:
123122
bob_chat_alice = snapshot.chat
124123
assert bob_chat_alice.get_basic_snapshot().is_contact_request
125124

126-
alice_chat = alice.create_group("Verified group", protect=True)
127-
logging.info("Bob joins verified group")
125+
alice_chat = alice.create_group("Group")
126+
logging.info("Bob joins the group")
128127
qr_code = alice_chat.get_qr_code()
129128
bob.secure_join(qr_code)
130129
while True:
@@ -148,8 +147,8 @@ def test_qr_readreceipt(acfactory) -> None:
148147
for joiner in [bob, charlie]:
149148
joiner.wait_for_securejoin_joiner_success()
150149

151-
logging.info("Alice creates a verified group")
152-
group = alice.create_group("Group", protect=True)
150+
logging.info("Alice creates a group")
151+
group = alice.create_group("Group")
153152

154153
alice_contact_bob = alice.create_contact(bob, "Bob")
155154
alice_contact_charlie = alice.create_contact(charlie, "Charlie")
@@ -214,10 +213,10 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
214213
"""Tests verified group recovery by reverifying then removing and adding a member back."""
215214
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
216215

217-
logging.info("ac1 creates verified group")
218-
chat = ac1.create_group("Verified group", protect=True)
216+
logging.info("ac1 creates a group")
217+
chat = ac1.create_group("Group")
219218

220-
logging.info("ac2 joins verified group")
219+
logging.info("ac2 joins the group")
221220
qr_code = chat.get_qr_code()
222221
ac2.secure_join(qr_code)
223222
ac2.wait_for_securejoin_joiner_success()
@@ -299,8 +298,8 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
299298
# we first create a fully joined verified group, and then start
300299
# joining a second time but interrupt it, to create pending bob state
301300

302-
logging.info("ac1: create verified group that ac2 fully joins")
303-
ch1 = ac1.create_group("Group", protect=True)
301+
logging.info("ac1: create a group that ac2 fully joins")
302+
ch1 = ac1.create_group("Group")
304303
qr_code = ch1.get_qr_code()
305304
ac2.secure_join(qr_code)
306305
ac1.wait_for_securejoin_inviter_success()
@@ -323,7 +322,7 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
323322
assert ac2.create_contact(ac3).get_snapshot().is_verified
324323

325324
logging.info("ac3: create a verified group VG with ac2")
326-
vg = ac3.create_group("ac3-created", protect=True)
325+
vg = ac3.create_group("ac3-created")
327326
vg.add_contact(ac3.create_contact(ac2))
328327

329328
# ensure ac2 receives message in VG
@@ -354,7 +353,7 @@ def test_qr_new_group_unblocked(acfactory):
354353
"""
355354

356355
ac1, ac2 = acfactory.get_online_accounts(2)
357-
ac1_chat = ac1.create_group("Group for joining", protect=True)
356+
ac1_chat = ac1.create_group("Group for joining")
358357
qr_code = ac1_chat.get_qr_code()
359358
ac2.secure_join(qr_code)
360359

@@ -379,7 +378,7 @@ def test_aeap_flow_verified(acfactory):
379378
addr, password = acfactory.get_credentials()
380379

381380
logging.info("ac1: create verified-group QR, ac2 scans and joins")
382-
chat = ac1.create_group("hello", protect=True)
381+
chat = ac1.create_group("hello")
383382
qr_code = chat.get_qr_code()
384383
logging.info("ac2: start QR-code based join-group protocol")
385384
ac2.secure_join(qr_code)
@@ -446,7 +445,7 @@ def test_gossip_verification(acfactory) -> None:
446445
assert carol_contact_alice_snapshot.is_verified
447446

448447
logging.info("Bob creates a Securejoin group")
449-
bob_group_chat = bob.create_group("Securejoin Group", protect=True)
448+
bob_group_chat = bob.create_group("Securejoin Group")
450449
bob_group_chat.add_contact(bob_contact_alice)
451450
bob_group_chat.add_contact(bob_contact_carol)
452451
bob_group_chat.send_message(text="Hello Securejoin group")
@@ -469,7 +468,7 @@ def test_securejoin_after_contact_resetup(acfactory) -> None:
469468
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
470469

471470
# ac3 creates protected group with ac1.
472-
ac3_chat = ac3.create_group("Verified group", protect=True)
471+
ac3_chat = ac3.create_group("Group")
473472

474473
# ac1 joins ac3 group.
475474
ac3_qr_code = ac3_chat.get_qr_code()
@@ -526,8 +525,8 @@ def test_securejoin_after_contact_resetup(acfactory) -> None:
526525
def test_withdraw_securejoin_qr(acfactory):
527526
alice, bob = acfactory.get_online_accounts(2)
528527

529-
logging.info("Alice creates a verified group")
530-
alice_chat = alice.create_group("Verified group", protect=True)
528+
logging.info("Alice creates a group")
529+
alice_chat = alice.create_group("Group")
531530
logging.info("Bob joins verified group")
532531

533532
qr_code = alice_chat.get_qr_code()

python/src/deltachat/account.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,18 +404,16 @@ def create_group_chat(
404404
self,
405405
name: str,
406406
contacts: Optional[List[Contact]] = None,
407-
verified: bool = False,
408407
) -> Chat:
409408
"""create a new group chat object.
410409
411410
Chats are unpromoted until the first message is sent.
412411
413412
:param contacts: list of contacts to add
414-
:param verified: if true only verified contacts can be added.
415413
:returns: a :class:`deltachat.chat.Chat` object.
416414
"""
417415
bytes_name = name.encode("utf8")
418-
chat_id = lib.dc_create_group_chat(self._dc_context, int(verified), bytes_name)
416+
chat_id = lib.dc_create_group_chat(self._dc_context, bytes_name)
419417
chat = Chat(self, chat_id)
420418
if contacts is not None:
421419
for contact in contacts:

python/src/deltachat/testplugin.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -604,20 +604,6 @@ def get_accepted_chat(self, ac1: Account, ac2: Account):
604604
ac2.create_chat(ac1)
605605
return ac1.create_chat(ac2)
606606

607-
def get_protected_chat(self, ac1: Account, ac2: Account):
608-
chat = ac1.create_group_chat("Protected Group", verified=True)
609-
qr = chat.get_join_qr()
610-
ac2.qr_join_chat(qr)
611-
ac2._evtracker.wait_securejoin_joiner_progress(1000)
612-
ev = ac2._evtracker.get_matching("DC_EVENT_MSGS_CHANGED")
613-
msg = ac2.get_message_by_id(ev.data2)
614-
assert msg is not None
615-
assert msg.text == "Messages are end-to-end encrypted."
616-
msg = ac2._evtracker.wait_next_incoming_message()
617-
assert msg is not None
618-
assert "Member Me " in msg.text and " added by " in msg.text
619-
return chat
620-
621607
def introduce_each_other(self, accounts, sending=True):
622608
to_wait = []
623609
for i, acc in enumerate(accounts):

python/tests/test_0_complex_or_slow.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_qr_verified_group_and_chatting(acfactory, lp):
118118
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
119119
ac1_addr = ac1.get_self_contact().addr
120120
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
121-
chat1 = ac1.create_group_chat("hello", verified=True)
121+
chat1 = ac1.create_group_chat("hello")
122122
qr = chat1.get_join_qr()
123123
lp.sec("ac2: start QR-code based join-group protocol")
124124
chat2 = ac2.qr_join_chat(qr)
@@ -171,8 +171,10 @@ def test_qr_verified_group_and_chatting(acfactory, lp):
171171
lp.sec("ac2: Check that ac1 verified ac3 for ac2")
172172
ac2_ac1_contact = ac2.get_contacts()[0]
173173
assert ac2.get_self_contact().get_verifier(ac2_ac1_contact).id == dc.const.DC_CONTACT_ID_SELF
174-
ac2_ac3_contact = ac2.get_contacts()[1]
175-
assert ac2.get_self_contact().get_verifier(ac2_ac3_contact).addr == ac1_addr
174+
for ac2_contact in chat2.get_contacts():
175+
if ac2_contact == ac2_ac1_contact or ac2_contact.id == dc.const.DC_CONTACT_ID_SELF:
176+
continue
177+
assert ac2.get_self_contact().get_verifier(ac2_contact).addr == ac1_addr
176178

177179
lp.sec("ac2: send message and let ac3 read it")
178180
chat2.send_text("hi")
@@ -264,7 +266,7 @@ def test_see_new_verified_member_after_going_online(acfactory, tmp_path, lp):
264266
ac1_offl.stop_io()
265267

266268
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
267-
chat = ac1.create_group_chat("hello", verified=True)
269+
chat = ac1.create_group_chat("hello")
268270
qr = chat.get_join_qr()
269271
lp.sec("ac2: start QR-code based join-group protocol")
270272
chat2 = ac2.qr_join_chat(qr)
@@ -318,7 +320,7 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp
318320
ac1.set_avatar(avatar_path)
319321

320322
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
321-
chat = ac1.create_group_chat("hello", verified=True)
323+
chat = ac1.create_group_chat("hello")
322324
qr = chat.get_join_qr()
323325
lp.sec("ac2: start QR-code based join-group protocol")
324326
ac2.qr_join_chat(qr)
@@ -371,7 +373,7 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
371373
ac2_offl.stop_io()
372374

373375
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
374-
chat1 = ac1.create_group_chat("hello", verified=True)
376+
chat1 = ac1.create_group_chat("hello")
375377
qr = chat1.get_join_qr()
376378
lp.sec("ac2: start QR-code based join-group protocol")
377379
chat2 = ac2.qr_join_chat(qr)
@@ -401,15 +403,6 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp):
401403
chat2.send_text("hi2")
402404

403405
lp.sec("ac2_offl: receiving message")
404-
ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
405-
msg_in = ac2_offl.get_message_by_id(ev.data2)
406-
assert msg_in.is_system_message()
407-
assert msg_in.text == "Messages are end-to-end encrypted."
408-
409-
# We need to consume one event that has data2=0
410-
ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
411-
assert ev.data2 == 0
412-
413406
ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
414407
msg_in = ac2_offl.get_message_by_id(ev.data2)
415408
assert not msg_in.is_system_message()

0 commit comments

Comments
 (0)