diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index d02f37348..be189c406 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -371,6 +371,11 @@ class Account(object): dc_array = ffi.gc(lib.dc_get_fresh_msgs(self._dc_context), lib.dc_array_unref) yield from iter_array(dc_array, lambda x: Message.from_db(self, x)) + def get_next_fresh_message(self) -> Message: + """Returns the oldest fresh message or waits for a new one to arrive.""" + msg_id = lib.dc_get_next_fresh_msg(self._dc_context) + return Message.from_db(self, msg_id) + def create_chat(self, obj) -> Chat: """Create a 1:1 chat with Account, Contact or e-mail address.""" return self.create_contact(obj).create_chat() diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 39cbae48c..b8dd62228 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -710,6 +710,7 @@ def test_send_and_receive_will_encrypt_decrypt(acfactory, lp): fresh_msgs = list(ac1.get_fresh_messages()) assert len(fresh_msgs) == 1 assert fresh_msgs[0] == msg3 + assert ac1.get_next_fresh_message() == msg3 msg3.mark_seen() assert not list(ac1.get_fresh_messages())