deltachat-rpc-client 1.158.0__tar.gz → 1.159.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {deltachat_rpc_client-1.158.0/src/deltachat_rpc_client.egg-info → deltachat_rpc_client-1.159.1}/PKG-INFO +1 -1
  2. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/pyproject.toml +1 -1
  3. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/_utils.py +3 -2
  4. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/account.py +5 -0
  5. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/const.py +1 -0
  6. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/message.py +4 -0
  7. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/pytestplugin.py +2 -2
  8. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1/src/deltachat_rpc_client.egg-info}/PKG-INFO +1 -1
  9. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client.egg-info/SOURCES.txt +1 -0
  10. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_account_events.py +1 -1
  11. deltachat_rpc_client-1.159.1/tests/test_multidevice.py +110 -0
  12. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_securejoin.py +3 -3
  13. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_something.py +38 -10
  14. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_vcard.py +1 -2
  15. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_webxdc.py +2 -4
  16. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/LICENSE +0 -0
  17. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/README.md +0 -0
  18. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/setup.cfg +0 -0
  19. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/__init__.py +0 -0
  20. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/chat.py +0 -0
  21. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/client.py +0 -0
  22. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/contact.py +0 -0
  23. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/deltachat.py +0 -0
  24. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/events.py +0 -0
  25. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/py.typed +0 -0
  26. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client/rpc.py +0 -0
  27. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client.egg-info/dependency_links.txt +0 -0
  28. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client.egg-info/entry_points.txt +0 -0
  29. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/src/deltachat_rpc_client.egg-info/top_level.txt +0 -0
  30. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_chatlist_events.py +0 -0
  31. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_iroh_webxdc.py +0 -0
  32. {deltachat_rpc_client-1.158.0 → deltachat_rpc_client-1.159.1}/tests/test_key_transfer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deltachat-rpc-client
3
- Version: 1.158.0
3
+ Version: 1.159.1
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: Intended Audience :: Developers
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deltachat-rpc-client"
7
- version = "1.158.0"
7
+ version = "1.159.1"
8
8
  description = "Python client for Delta Chat core JSON-RPC interface"
9
9
  classifiers = [
10
10
  "Development Status :: 5 - Production/Stable",
@@ -1,4 +1,5 @@
1
1
  import argparse
2
+ import os
2
3
  import re
3
4
  import sys
4
5
  from threading import Thread
@@ -89,8 +90,8 @@ def _run_cli(
89
90
  help="accounts folder (default: current working directory)",
90
91
  nargs="?",
91
92
  )
92
- parser.add_argument("--email", action="store", help="email address")
93
- parser.add_argument("--password", action="store", help="password")
93
+ parser.add_argument("--email", action="store", help="email address", default=os.getenv("DELTACHAT_EMAIL"))
94
+ parser.add_argument("--password", action="store", help="password", default=os.getenv("DELTACHAT_PASSWORD"))
94
95
  args = parser.parse_args(argv[1:])
95
96
 
96
97
  with Rpc(accounts_dir=args.accounts_dir, **kwargs) as rpc:
@@ -110,6 +110,11 @@ class Account:
110
110
  """Configure an account."""
111
111
  yield self._rpc.configure.future(self.id)
112
112
 
113
+ @futuremethod
114
+ def add_transport(self, params):
115
+ """Add a new transport."""
116
+ yield self._rpc.add_transport.future(self.id, params)
117
+
113
118
  def bring_online(self):
114
119
  """Start I/O and wait until IMAP becomes IDLE."""
115
120
  self.start_io()
@@ -48,6 +48,7 @@ class EventType(str, Enum):
48
48
  MSG_READ = "MsgRead"
49
49
  MSG_DELETED = "MsgDeleted"
50
50
  CHAT_MODIFIED = "ChatModified"
51
+ CHAT_DELETED = "ChatDeleted"
51
52
  CHAT_EPHEMERAL_TIMER_MODIFIED = "ChatEphemeralTimerModified"
52
53
  CONTACTS_CHANGED = "ContactsChanged"
53
54
  LOCATION_CHANGED = "LocationChanged"
@@ -64,6 +64,10 @@ class Message:
64
64
  def get_webxdc_status_updates(self, last_known_serial: int = 0) -> list:
65
65
  return json.loads(self._rpc.get_webxdc_status_updates(self.account.id, self.id, last_known_serial))
66
66
 
67
+ def get_info(self) -> str:
68
+ """Return message info."""
69
+ return self._rpc.get_message_info(self.account.id, self.id)
70
+
67
71
  def get_webxdc_info(self) -> dict:
68
72
  return self._rpc.get_webxdc_info(self.account.id, self.id)
69
73
 
@@ -34,7 +34,7 @@ class ACFactory:
34
34
  addr, password = self.get_credentials()
35
35
  account = self.get_unconfigured_account()
36
36
  params = {"addr": addr, "password": password}
37
- yield account._rpc.add_transport.future(account.id, params)
37
+ yield account.add_transport.future(params)
38
38
 
39
39
  assert account.is_configured()
40
40
  return account
@@ -79,7 +79,7 @@ class ACFactory:
79
79
  ) -> Message:
80
80
  if not from_account:
81
81
  from_account = (self.get_online_accounts(1))[0]
82
- to_contact = from_account.create_contact(to_account.get_config("addr"))
82
+ to_contact = from_account.create_contact(to_account)
83
83
  if group:
84
84
  to_chat = from_account.create_group(group)
85
85
  to_chat.add_contact(to_contact)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deltachat-rpc-client
3
- Version: 1.158.0
3
+ Version: 1.159.1
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: Intended Audience :: Developers
@@ -23,6 +23,7 @@ tests/test_account_events.py
23
23
  tests/test_chatlist_events.py
24
24
  tests/test_iroh_webxdc.py
25
25
  tests/test_key_transfer.py
26
+ tests/test_multidevice.py
26
27
  tests/test_securejoin.py
27
28
  tests/test_something.py
28
29
  tests/test_vcard.py
@@ -17,7 +17,7 @@ def test_event_on_configuration(acfactory: ACFactory) -> None:
17
17
  account = acfactory.get_unconfigured_account()
18
18
  account.clear_all_events()
19
19
  assert not account.is_configured()
20
- future = account._rpc.add_transport.future(account.id, {"addr": addr, "password": password})
20
+ future = account.add_transport.future({"addr": addr, "password": password})
21
21
  while True:
22
22
  event = account.wait_for_event()
23
23
  if event.kind == EventType.ACCOUNTS_ITEM_CHANGED:
@@ -0,0 +1,110 @@
1
+ from imap_tools import AND
2
+
3
+ from deltachat_rpc_client import EventType
4
+ from deltachat_rpc_client.const import MessageState
5
+
6
+
7
+ def test_one_account_send_bcc_setting(acfactory, log, direct_imap):
8
+ ac1, ac2 = acfactory.get_online_accounts(2)
9
+ ac1_clone = ac1.clone()
10
+ ac1_clone.bring_online()
11
+
12
+ log.section("send out message without bcc to ourselves")
13
+ ac1.set_config("bcc_self", "0")
14
+ chat = ac1.create_chat(ac2)
15
+ self_addr = ac1.get_config("addr")
16
+ other_addr = ac2.get_config("addr")
17
+
18
+ msg_out = chat.send_text("message1")
19
+ assert not msg_out.get_snapshot().is_forwarded
20
+
21
+ # wait for send out (no BCC)
22
+ ev = ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT)
23
+ assert ac1.get_config("bcc_self") == "0"
24
+
25
+ assert self_addr not in ev.msg
26
+ assert other_addr in ev.msg
27
+
28
+ log.section("ac1: setting bcc_self=1")
29
+ ac1.set_config("bcc_self", "1")
30
+
31
+ log.section("send out message with bcc to ourselves")
32
+ msg_out = chat.send_text("message2")
33
+
34
+ # wait for send out (BCC)
35
+ ev = ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT)
36
+ assert ac1.get_config("bcc_self") == "1"
37
+
38
+ # Second client receives only second message, but not the first.
39
+ ev_msg = ac1_clone.wait_for_event(EventType.MSGS_CHANGED)
40
+ assert ac1_clone.get_message_by_id(ev_msg.msg_id).get_snapshot().text == msg_out.get_snapshot().text
41
+
42
+ # now make sure we are sending message to ourselves too
43
+ assert self_addr in ev.msg
44
+ assert self_addr in ev.msg
45
+
46
+ # BCC-self messages are marked as seen by the sender device.
47
+ while True:
48
+ event = ac1.wait_for_event()
49
+ if event.kind == EventType.INFO and event.msg.endswith("Marked messages 1 in folder INBOX as seen."):
50
+ break
51
+
52
+ # Check that the message is marked as seen on IMAP.
53
+ ac1_direct_imap = direct_imap(ac1)
54
+ ac1_direct_imap.connect()
55
+ ac1_direct_imap.select_folder("Inbox")
56
+ assert len(list(ac1_direct_imap.conn.fetch(AND(seen=True)))) == 1
57
+
58
+
59
+ def test_multidevice_sync_seen(acfactory, log):
60
+ """Test that message marked as seen on one device is marked as seen on another."""
61
+ ac1, ac2 = acfactory.get_online_accounts(2)
62
+ ac1_clone = ac1.clone()
63
+ ac1_clone.bring_online()
64
+
65
+ ac1.set_config("bcc_self", "1")
66
+ ac1_clone.set_config("bcc_self", "1")
67
+
68
+ ac1_chat = ac1.create_chat(ac2)
69
+ ac1_clone_chat = ac1_clone.create_chat(ac2)
70
+ ac2_chat = ac2.create_chat(ac1)
71
+
72
+ log.section("Send a message from ac2 to ac1 and check that it's 'fresh'")
73
+ ac2_chat.send_text("Hi")
74
+ ac1_message = ac1.wait_for_incoming_msg()
75
+ ac1_clone_message = ac1_clone.wait_for_incoming_msg()
76
+ assert ac1_chat.get_fresh_message_count() == 1
77
+ assert ac1_clone_chat.get_fresh_message_count() == 1
78
+ assert ac1_message.get_snapshot().state == MessageState.IN_FRESH
79
+ assert ac1_clone_message.get_snapshot().state == MessageState.IN_FRESH
80
+
81
+ log.section("ac1 marks message as seen on the first device")
82
+ ac1.mark_seen_messages([ac1_message])
83
+ assert ac1_message.get_snapshot().state == MessageState.IN_SEEN
84
+
85
+ log.section("ac1 clone detects that message is marked as seen")
86
+ ev = ac1_clone.wait_for_event(EventType.MSGS_NOTICED)
87
+ assert ev.chat_id == ac1_clone_chat.id
88
+
89
+ log.section("Send an ephemeral message from ac2 to ac1")
90
+ ac2_chat.set_ephemeral_timer(60)
91
+ ac1.wait_for_event(EventType.CHAT_EPHEMERAL_TIMER_MODIFIED)
92
+ ac1.wait_for_incoming_msg()
93
+ ac1_clone.wait_for_event(EventType.CHAT_EPHEMERAL_TIMER_MODIFIED)
94
+ ac1_clone.wait_for_incoming_msg()
95
+
96
+ ac2_chat.send_text("Foobar")
97
+ ac1_message = ac1.wait_for_incoming_msg()
98
+ ac1_clone_message = ac1_clone.wait_for_incoming_msg()
99
+ assert "Ephemeral timer: 60\n" in ac1_message.get_info()
100
+ assert "Expires: " not in ac1_clone_message.get_info()
101
+ assert "Ephemeral timer: 60\n" in ac1_message.get_info()
102
+ assert "Expires: " not in ac1_clone_message.get_info()
103
+
104
+ ac1_message.mark_seen()
105
+ assert "Expires: " in ac1_message.get_info()
106
+ ev = ac1_clone.wait_for_event(EventType.MSGS_NOTICED)
107
+ assert ev.chat_id == ac1_clone_chat.id
108
+ assert ac1_clone_message.get_snapshot().state == MessageState.IN_SEEN
109
+ # Test that the timer is started on the second device after synchronizing the seen status.
110
+ assert "Expires: " in ac1_clone_message.get_info()
@@ -89,7 +89,7 @@ def test_qr_securejoin(acfactory, protect):
89
89
  assert alice_contact_bob_snapshot.is_verified
90
90
 
91
91
  snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
92
- assert snapshot.text == "Member Me ({}) added by {}.".format(bob.get_config("addr"), alice.get_config("addr"))
92
+ assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr"))
93
93
  assert snapshot.chat.get_basic_snapshot().is_protected == protect
94
94
 
95
95
  # Test that Bob verified Alice's profile.
@@ -563,7 +563,7 @@ def test_securejoin_after_contact_resetup(acfactory) -> None:
563
563
 
564
564
  # ac1 waits for member added message and creates a QR code.
565
565
  snapshot = ac1.get_message_by_id(ac1.wait_for_incoming_msg_event().msg_id).get_snapshot()
566
- assert snapshot.text == "Member Me ({}) added by {}.".format(ac1.get_config("addr"), ac3.get_config("addr"))
566
+ assert snapshot.text == "Member Me added by {}.".format(ac3.get_config("addr"))
567
567
  ac1_qr_code = snapshot.chat.get_qr_code()
568
568
 
569
569
  # ac2 verifies ac1
@@ -646,7 +646,7 @@ def test_withdraw_securejoin_qr(acfactory):
646
646
  alice.clear_all_events()
647
647
 
648
648
  snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
649
- assert snapshot.text == "Member Me ({}) added by {}.".format(bob.get_config("addr"), alice.get_config("addr"))
649
+ assert snapshot.text == "Member Me added by {}.".format(alice.get_config("addr"))
650
650
  assert snapshot.chat.get_basic_snapshot().is_protected
651
651
  bob_chat.leave()
652
652
 
@@ -63,8 +63,7 @@ def test_acfactory(acfactory) -> None:
63
63
  def test_configure_starttls(acfactory) -> None:
64
64
  addr, password = acfactory.get_credentials()
65
65
  account = acfactory.get_unconfigured_account()
66
- account._rpc.add_transport(
67
- account.id,
66
+ account.add_transport(
68
67
  {
69
68
  "addr": addr,
70
69
  "password": password,
@@ -81,8 +80,7 @@ def test_configure_ip(acfactory) -> None:
81
80
  ip_address = socket.gethostbyname(addr.rsplit("@")[-1])
82
81
 
83
82
  with pytest.raises(JsonRpcError):
84
- account._rpc.add_transport(
85
- account.id,
83
+ account.add_transport(
86
84
  {
87
85
  "addr": addr,
88
86
  "password": password,
@@ -96,8 +94,7 @@ def test_configure_alternative_port(acfactory) -> None:
96
94
  """Test that configuration with alternative port 443 works."""
97
95
  addr, password = acfactory.get_credentials()
98
96
  account = acfactory.get_unconfigured_account()
99
- account._rpc.add_transport(
100
- account.id,
97
+ account.add_transport(
101
98
  {
102
99
  "addr": addr,
103
100
  "password": password,
@@ -111,8 +108,7 @@ def test_configure_alternative_port(acfactory) -> None:
111
108
  def test_list_transports(acfactory) -> None:
112
109
  addr, password = acfactory.get_credentials()
113
110
  account = acfactory.get_unconfigured_account()
114
- account._rpc.add_transport(
115
- account.id,
111
+ account.add_transport(
116
112
  {
117
113
  "addr": addr,
118
114
  "password": password,
@@ -424,7 +420,7 @@ def test_wait_next_messages(acfactory) -> None:
424
420
  addr, password = acfactory.get_credentials()
425
421
  bot = acfactory.get_unconfigured_account()
426
422
  bot.set_config("bot", "1")
427
- bot._rpc.add_transport(bot.id, {"addr": addr, "password": password})
423
+ bot.add_transport({"addr": addr, "password": password})
428
424
  assert bot.is_configured()
429
425
 
430
426
  # There are no old messages and the call returns immediately.
@@ -607,7 +603,7 @@ def test_reactions_for_a_reordering_move(acfactory, direct_imap):
607
603
 
608
604
  addr, password = acfactory.get_credentials()
609
605
  ac2 = acfactory.get_unconfigured_account()
610
- ac2._rpc.add_transport(ac2.id, {"addr": addr, "password": password})
606
+ ac2.add_transport({"addr": addr, "password": password})
611
607
  ac2.set_config("mvbox_move", "1")
612
608
  assert ac2.is_configured()
613
609
 
@@ -797,3 +793,35 @@ def test_rename_group(acfactory):
797
793
  alice_group.set_name(name)
798
794
  bob.wait_for_incoming_msg_event()
799
795
  assert bob_chat.get_basic_snapshot().name == name
796
+
797
+
798
+ def test_get_all_accounts_deadlock(rpc):
799
+ """Regression test for get_all_accounts deadlock."""
800
+ for _ in range(100):
801
+ all_accounts = rpc.get_all_accounts.future()
802
+ rpc.add_account()
803
+ all_accounts()
804
+
805
+
806
+ def test_delete_deltachat_folder(acfactory, direct_imap):
807
+ """Test that DeltaChat folder is recreated if user deletes it manually."""
808
+ ac1 = acfactory.new_configured_account()
809
+ ac1.set_config("mvbox_move", "1")
810
+ ac1.bring_online()
811
+
812
+ ac1_direct_imap = direct_imap(ac1)
813
+ ac1_direct_imap.conn.folder.delete("DeltaChat")
814
+ assert "DeltaChat" not in ac1_direct_imap.list_folders()
815
+
816
+ # Wait until new folder is created and UIDVALIDITY is updated.
817
+ while True:
818
+ event = ac1.wait_for_event()
819
+ if event.kind == EventType.INFO and "uid/validity change folder DeltaChat" in event.msg:
820
+ break
821
+
822
+ ac2 = acfactory.get_online_account()
823
+ ac2.create_chat(ac1).send_text("hello")
824
+ msg = ac1.wait_for_incoming_msg().get_snapshot()
825
+ assert msg.text == "hello"
826
+
827
+ assert "DeltaChat" in ac1_direct_imap.list_folders()
@@ -1,8 +1,7 @@
1
1
  def test_vcard(acfactory) -> None:
2
2
  alice, bob = acfactory.get_online_accounts(2)
3
3
 
4
- bob_addr = bob.get_config("addr")
5
- alice_contact_bob = alice.create_contact(bob_addr, "Bob")
4
+ alice_contact_bob = alice.create_contact(bob, "Bob")
6
5
  alice_contact_charlie = alice.create_contact("charlie@example.org", "Charlie")
7
6
 
8
7
  alice_chat_bob = alice_contact_bob.create_chat()
@@ -1,8 +1,7 @@
1
1
  def test_webxdc(acfactory) -> None:
2
2
  alice, bob = acfactory.get_online_accounts(2)
3
3
 
4
- bob_addr = bob.get_config("addr")
5
- alice_contact_bob = alice.create_contact(bob_addr, "Bob")
4
+ alice_contact_bob = alice.create_contact(bob, "Bob")
6
5
  alice_chat_bob = alice_contact_bob.create_chat()
7
6
  alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc")
8
7
 
@@ -45,8 +44,7 @@ def test_webxdc(acfactory) -> None:
45
44
  def test_webxdc_insert_lots_of_updates(acfactory) -> None:
46
45
  alice, bob = acfactory.get_online_accounts(2)
47
46
 
48
- bob_addr = bob.get_config("addr")
49
- alice_contact_bob = alice.create_contact(bob_addr, "Bob")
47
+ alice_contact_bob = alice.create_contact(bob, "Bob")
50
48
  alice_chat_bob = alice_contact_bob.create_chat()
51
49
  message = alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc")
52
50