api!(deltachat-rpc-client): make {Account,Chat}.get_qr_code() return no SVG

This is a breaking change, old method is renamed into `get_qr_code_svg()`.
This commit is contained in:
link2xt
2024-06-19 08:28:54 +00:00
parent 9cbc9bf2bc
commit 8ddc05923b
3 changed files with 34 additions and 26 deletions

View File

@@ -250,12 +250,16 @@ class Account:
""" """
return Chat(self, self._rpc.secure_join(self.id, qrdata)) return Chat(self, self._rpc.secure_join(self.id, qrdata))
def get_qr_code(self) -> tuple[str, str]: def get_qr_code(self) -> str:
"""Get Setup-Contact QR Code text and SVG data. """Get Setup-Contact QR Code text.
this data needs to be transferred to another Delta Chat account This data needs to be transferred to another Delta Chat account
in a second channel, typically used by mobiles with QRcode-show + scan UX. in a second channel, typically used by mobiles with QRcode-show + scan UX.
""" """
return self._rpc.get_chat_securejoin_qr_code(self.id, None)
def get_qr_code_svg(self) -> tuple[str, str]:
"""Get Setup-Contact QR code text and SVG."""
return self._rpc.get_chat_securejoin_qr_code_svg(self.id, None) return self._rpc.get_chat_securejoin_qr_code_svg(self.id, None)
def get_message_by_id(self, msg_id: int) -> Message: def get_message_by_id(self, msg_id: int) -> Message:

View File

@@ -96,7 +96,11 @@ class Chat:
"""Return encryption info for this chat.""" """Return encryption info for this chat."""
return self._rpc.get_chat_encryption_info(self.account.id, self.id) return self._rpc.get_chat_encryption_info(self.account.id, self.id)
def get_qr_code(self) -> tuple[str, str]: def get_qr_code(self) -> str:
"""Get Join-Group QR code text."""
return self._rpc.get_chat_securejoin_qr_code(self.account.id, self.id)
def get_qr_code_svg(self) -> tuple[str, str]:
"""Get Join-Group QR code text and SVG data.""" """Get Join-Group QR code text and SVG data."""
return self._rpc.get_chat_securejoin_qr_code_svg(self.account.id, self.id) return self._rpc.get_chat_securejoin_qr_code_svg(self.account.id, self.id)

View File

@@ -7,7 +7,7 @@ from deltachat_rpc_client import Chat, EventType, SpecialContactId
def test_qr_setup_contact(acfactory, tmp_path) -> None: def test_qr_setup_contact(acfactory, tmp_path) -> None:
alice, bob = acfactory.get_online_accounts(2) alice, bob = acfactory.get_online_accounts(2)
qr_code, _svg = alice.get_qr_code() qr_code = alice.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
alice.wait_for_securejoin_inviter_success() alice.wait_for_securejoin_inviter_success()
@@ -46,7 +46,7 @@ def test_qr_securejoin(acfactory, protect):
assert alice_chat.get_basic_snapshot().is_protected == protect assert alice_chat.get_basic_snapshot().is_protected == protect
logging.info("Bob joins verified group") logging.info("Bob joins verified group")
qr_code, _svg = alice_chat.get_qr_code() qr_code = alice_chat.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
# Check that at least some of the handshake messages are deleted. # Check that at least some of the handshake messages are deleted.
@@ -91,7 +91,7 @@ def test_qr_securejoin_contact_request(acfactory) -> None:
alice_chat = alice.create_group("Verified group", protect=True) alice_chat = alice.create_group("Verified group", protect=True)
logging.info("Bob joins verified group") logging.info("Bob joins verified group")
qr_code, _svg = alice_chat.get_qr_code() qr_code = alice_chat.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
while True: while True:
event = bob.wait_for_event() event = bob.wait_for_event()
@@ -106,7 +106,7 @@ def test_qr_readreceipt(acfactory) -> None:
alice, bob, charlie = acfactory.get_online_accounts(3) alice, bob, charlie = acfactory.get_online_accounts(3)
logging.info("Bob and Charlie setup contact with Alice") logging.info("Bob and Charlie setup contact with Alice")
qr_code, _svg = alice.get_qr_code() qr_code = alice.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
charlie.secure_join(qr_code) charlie.secure_join(qr_code)
@@ -168,13 +168,13 @@ def test_setup_contact_resetup(acfactory) -> None:
"""Tests that setup contact works after Alice resets the device and changes the key.""" """Tests that setup contact works after Alice resets the device and changes the key."""
alice, bob = acfactory.get_online_accounts(2) alice, bob = acfactory.get_online_accounts(2)
qr_code, _svg = alice.get_qr_code() qr_code = alice.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
bob.wait_for_securejoin_joiner_success() bob.wait_for_securejoin_joiner_success()
alice = acfactory.resetup_account(alice) alice = acfactory.resetup_account(alice)
qr_code, _svg = alice.get_qr_code() qr_code = alice.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
bob.wait_for_securejoin_joiner_success() bob.wait_for_securejoin_joiner_success()
@@ -188,7 +188,7 @@ def test_verified_group_recovery(acfactory) -> None:
assert chat.get_basic_snapshot().is_protected assert chat.get_basic_snapshot().is_protected
logging.info("ac2 joins verified group") logging.info("ac2 joins verified group")
qr_code, _svg = chat.get_qr_code() qr_code = chat.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac2.wait_for_securejoin_joiner_success() ac2.wait_for_securejoin_joiner_success()
@@ -205,7 +205,7 @@ def test_verified_group_recovery(acfactory) -> None:
ac2 = acfactory.resetup_account(ac2) ac2 = acfactory.resetup_account(ac2)
logging.info("ac2 reverifies with ac3") logging.info("ac2 reverifies with ac3")
qr_code, _svg = ac3.get_qr_code() qr_code = ac3.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac2.wait_for_securejoin_joiner_success() ac2.wait_for_securejoin_joiner_success()
@@ -252,7 +252,7 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
assert chat.get_basic_snapshot().is_protected assert chat.get_basic_snapshot().is_protected
logging.info("ac2 joins verified group") logging.info("ac2 joins verified group")
qr_code, _svg = chat.get_qr_code() qr_code = chat.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac2.wait_for_securejoin_joiner_success() ac2.wait_for_securejoin_joiner_success()
@@ -269,7 +269,7 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
ac2 = acfactory.resetup_account(ac2) ac2 = acfactory.resetup_account(ac2)
logging.info("ac2 reverifies with ac3") logging.info("ac2 reverifies with ac3")
qr_code, _svg = ac3.get_qr_code() qr_code = ac3.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac2.wait_for_securejoin_joiner_success() ac2.wait_for_securejoin_joiner_success()
@@ -336,7 +336,7 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
ac1, ac2, ac3, ac4 = acfactory.get_online_accounts(4) ac1, ac2, ac3, ac4 = acfactory.get_online_accounts(4)
logging.info("ac3: verify with ac2") logging.info("ac3: verify with ac2")
qr_code, _svg = ac2.get_qr_code() qr_code = ac2.get_qr_code()
ac3.secure_join(qr_code) ac3.secure_join(qr_code)
ac2.wait_for_securejoin_inviter_success() ac2.wait_for_securejoin_inviter_success()
@@ -346,7 +346,7 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
logging.info("ac1: create verified group that ac2 fully joins") logging.info("ac1: create verified group that ac2 fully joins")
ch1 = ac1.create_group("Group", protect=True) ch1 = ac1.create_group("Group", protect=True)
qr_code, _svg = ch1.get_qr_code() qr_code = ch1.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac1.wait_for_securejoin_inviter_success() ac1.wait_for_securejoin_inviter_success()
@@ -359,7 +359,7 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
break break
logging.info("ac1: let ac2 join again but shutoff ac1 in the middle of securejoin") logging.info("ac1: let ac2 join again but shutoff ac1 in the middle of securejoin")
qr_code, _svg = ch1.get_qr_code() qr_code = ch1.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac1.remove() ac1.remove()
logging.info("ac2 now has pending bobstate but ac1 is shutoff") logging.info("ac2 now has pending bobstate but ac1 is shutoff")
@@ -381,7 +381,7 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
break break
logging.info("ac3: create a join-code for group VG and let ac4 join, check that ac2 got it") logging.info("ac3: create a join-code for group VG and let ac4 join, check that ac2 got it")
qr_code, _svg = vg.get_qr_code() qr_code = vg.get_qr_code()
ac4.secure_join(qr_code) ac4.secure_join(qr_code)
ac3.wait_for_securejoin_inviter_success() ac3.wait_for_securejoin_inviter_success()
while 1: while 1:
@@ -402,7 +402,7 @@ def test_qr_new_group_unblocked(acfactory):
ac1, ac2 = acfactory.get_online_accounts(2) ac1, ac2 = acfactory.get_online_accounts(2)
ac1_chat = ac1.create_group("Group for joining", protect=True) ac1_chat = ac1.create_group("Group for joining", protect=True)
qr_code, _svg = ac1_chat.get_qr_code() qr_code = ac1_chat.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac1.wait_for_securejoin_inviter_success() ac1.wait_for_securejoin_inviter_success()
@@ -425,7 +425,7 @@ def test_aeap_flow_verified(acfactory):
logging.info("ac1: create verified-group QR, ac2 scans and joins") logging.info("ac1: create verified-group QR, ac2 scans and joins")
chat = ac1.create_group("hello", protect=True) chat = ac1.create_group("hello", protect=True)
assert chat.get_basic_snapshot().is_protected assert chat.get_basic_snapshot().is_protected
qr_code, _svg = chat.get_qr_code() qr_code = chat.get_qr_code()
logging.info("ac2: start QR-code based join-group protocol") logging.info("ac2: start QR-code based join-group protocol")
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac1.wait_for_securejoin_inviter_success() ac1.wait_for_securejoin_inviter_success()
@@ -464,12 +464,12 @@ def test_gossip_verification(acfactory) -> None:
alice, bob, carol = acfactory.get_online_accounts(3) alice, bob, carol = acfactory.get_online_accounts(3)
# Bob verifies Alice. # Bob verifies Alice.
qr_code, _svg = alice.get_qr_code() qr_code = alice.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
bob.wait_for_securejoin_joiner_success() bob.wait_for_securejoin_joiner_success()
# Bob verifies Carol. # Bob verifies Carol.
qr_code, _svg = carol.get_qr_code() qr_code = carol.get_qr_code()
bob.secure_join(qr_code) bob.secure_join(qr_code)
bob.wait_for_securejoin_joiner_success() bob.wait_for_securejoin_joiner_success()
@@ -520,16 +520,16 @@ def test_securejoin_after_contact_resetup(acfactory) -> None:
ac3_chat = ac3.create_group("Verified group", protect=True) ac3_chat = ac3.create_group("Verified group", protect=True)
# ac1 joins ac3 group. # ac1 joins ac3 group.
ac3_qr_code, _svg = ac3_chat.get_qr_code() ac3_qr_code = ac3_chat.get_qr_code()
ac1.secure_join(ac3_qr_code) ac1.secure_join(ac3_qr_code)
ac1.wait_for_securejoin_joiner_success() ac1.wait_for_securejoin_joiner_success()
# ac1 waits for member added message and creates a QR code. # ac1 waits for member added message and creates a QR code.
snapshot = ac1.get_message_by_id(ac1.wait_for_incoming_msg_event().msg_id).get_snapshot() snapshot = ac1.get_message_by_id(ac1.wait_for_incoming_msg_event().msg_id).get_snapshot()
ac1_qr_code, _svg = snapshot.chat.get_qr_code() ac1_qr_code = snapshot.chat.get_qr_code()
# ac2 verifies ac1 # ac2 verifies ac1
qr_code, _svg = ac1.get_qr_code() qr_code = ac1.get_qr_code()
ac2.secure_join(qr_code) ac2.secure_join(qr_code)
ac2.wait_for_securejoin_joiner_success() ac2.wait_for_securejoin_joiner_success()
@@ -589,7 +589,7 @@ def test_withdraw_securejoin_qr(acfactory):
assert alice_chat.get_basic_snapshot().is_protected assert alice_chat.get_basic_snapshot().is_protected
logging.info("Bob joins verified group") logging.info("Bob joins verified group")
qr_code, _svg = alice_chat.get_qr_code() qr_code = alice_chat.get_qr_code()
bob_chat = bob.secure_join(qr_code) bob_chat = bob.secure_join(qr_code)
bob.wait_for_securejoin_joiner_success() bob.wait_for_securejoin_joiner_success()