changeset 4159:54b8cf8c8daf

core (memory/memory): fix the use of empty `from_jid` and `to_jid` in `history_get`
author Goffi <goffi@goffi.org>
date Tue, 28 Nov 2023 17:25:47 +0100
parents 83d8d8500bc2
children 6a0066ea5c97
files libervia/backend/memory/memory.py
diffstat 1 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/backend/memory/memory.py	Wed Nov 22 15:11:25 2023 +0100
+++ b/libervia/backend/memory/memory.py	Tue Nov 28 17:25:47 2023 +0100
@@ -627,26 +627,36 @@
 
     def _history_get(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True,
                     filters=None, profile=C.PROF_KEY_NONE):
-        d = self.history_get(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between,
-                               filters, profile)
+        from_jid = jid.JID(from_jid_s) if from_jid_s else None
+        to_jid = jid.JID(to_jid_s) if to_jid_s else None
+        d = self.history_get(
+            from_jid, to_jid, limit, between, filters, profile
+        )
         d.addCallback(self._history_get_serialise)
         return d
 
-    def history_get(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True,
-                   filters=None, profile=C.PROF_KEY_NONE):
+    def history_get(
+        self,
+        from_jid: jid.JID|None,
+        to_jid: jid.JID|None,
+        limit: int = C.HISTORY_LIMIT_NONE,
+        between: bool = True,
+        filters: dict[str, str]|None = None,
+        profile: str = C.PROF_KEY_NONE
+    ) -> defer.Deferred[list]:
         """Retrieve messages in history
 
-        @param from_jid (JID): source JID (full, or bare for catchall)
-        @param to_jid (JID): dest JID (full, or bare for catchall)
-        @param limit (int): maximum number of messages to get:
+        @param from_jid: source JID (full, or bare for catchall)
+        @param to_jid: dest JID (full, or bare for catchall)
+        @param limit: maximum number of messages to get:
             - 0 for no message (returns the empty list)
             - C.HISTORY_LIMIT_NONE or None for unlimited
             - C.HISTORY_LIMIT_DEFAULT to use the HISTORY_LIMIT parameter value
-        @param between (bool): confound source and dest (ignore the direction)
-        @param filters (dict[unicode, unicode]): pattern to filter the history results
+        @param between: confound source and dest (ignore the direction)
+        @param filters: pattern to filter the history results
             (see bridge API for details)
-        @param profile (str): %(doc_profile)s
-        @return (D(list)): list of message data as in [message_new]
+        @param profile: %(doc_profile)s
+        @return: list of message data as in [message_new]
         """
         assert profile != C.PROF_KEY_NONE
         if limit == C.HISTORY_LIMIT_DEFAULT: