mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Add get_fresh_messages_in_arrival_order() call
This commit is contained in:
@@ -64,5 +64,16 @@ class Account:
|
|||||||
return Chat(self.rpc, self.account_id, self.chat_id)
|
return Chat(self.rpc, self.account_id, self.chat_id)
|
||||||
|
|
||||||
async def get_fresh_messages(self):
|
async def get_fresh_messages(self):
|
||||||
|
"""Return the list of fresh messages, newest messages first.
|
||||||
|
|
||||||
|
This call is intended for displaying notifications.
|
||||||
|
If you are writing a bot, use get_fresh_messages_in_arrival_order instead,
|
||||||
|
to process oldest messages first.
|
||||||
|
"""
|
||||||
fresh_msg_ids = await self.rpc.get_fresh_msgs(self.account_id)
|
fresh_msg_ids = await self.rpc.get_fresh_msgs(self.account_id)
|
||||||
return [Message(self.rpc, self.account_id, msg_id) for msg_id in fresh_msg_ids]
|
return [Message(self.rpc, self.account_id, msg_id) for msg_id in fresh_msg_ids]
|
||||||
|
|
||||||
|
async def get_fresh_messages_in_arrival_order(self):
|
||||||
|
"""Return the list of fresh messages sorted in the order of their arrival, with ascending IDs."""
|
||||||
|
fresh_msg_ids = sorted(await self.rpc.get_fresh_msgs(self.account_id))
|
||||||
|
return [Message(self.rpc, self.account_id, msg_id) for msg_id in fresh_msg_ids]
|
||||||
|
|||||||
Reference in New Issue
Block a user