mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 06:56:29 +03:00
Add python bindings for get_next_fresh_message()
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user