comparison libervia/backend/memory/memory.py @ 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 02f0adc745c6
children 730f542e4ad0
comparison
equal deleted inserted replaced
4158:83d8d8500bc2 4159:54b8cf8c8daf
625 subject, mess_type, extra in history_data 625 subject, mess_type, extra in history_data
626 ] 626 ]
627 627
628 def _history_get(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True, 628 def _history_get(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True,
629 filters=None, profile=C.PROF_KEY_NONE): 629 filters=None, profile=C.PROF_KEY_NONE):
630 d = self.history_get(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between, 630 from_jid = jid.JID(from_jid_s) if from_jid_s else None
631 filters, profile) 631 to_jid = jid.JID(to_jid_s) if to_jid_s else None
632 d = self.history_get(
633 from_jid, to_jid, limit, between, filters, profile
634 )
632 d.addCallback(self._history_get_serialise) 635 d.addCallback(self._history_get_serialise)
633 return d 636 return d
634 637
635 def history_get(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, 638 def history_get(
636 filters=None, profile=C.PROF_KEY_NONE): 639 self,
640 from_jid: jid.JID|None,
641 to_jid: jid.JID|None,
642 limit: int = C.HISTORY_LIMIT_NONE,
643 between: bool = True,
644 filters: dict[str, str]|None = None,
645 profile: str = C.PROF_KEY_NONE
646 ) -> defer.Deferred[list]:
637 """Retrieve messages in history 647 """Retrieve messages in history
638 648
639 @param from_jid (JID): source JID (full, or bare for catchall) 649 @param from_jid: source JID (full, or bare for catchall)
640 @param to_jid (JID): dest JID (full, or bare for catchall) 650 @param to_jid: dest JID (full, or bare for catchall)
641 @param limit (int): maximum number of messages to get: 651 @param limit: maximum number of messages to get:
642 - 0 for no message (returns the empty list) 652 - 0 for no message (returns the empty list)
643 - C.HISTORY_LIMIT_NONE or None for unlimited 653 - C.HISTORY_LIMIT_NONE or None for unlimited
644 - C.HISTORY_LIMIT_DEFAULT to use the HISTORY_LIMIT parameter value 654 - C.HISTORY_LIMIT_DEFAULT to use the HISTORY_LIMIT parameter value
645 @param between (bool): confound source and dest (ignore the direction) 655 @param between: confound source and dest (ignore the direction)
646 @param filters (dict[unicode, unicode]): pattern to filter the history results 656 @param filters: pattern to filter the history results
647 (see bridge API for details) 657 (see bridge API for details)
648 @param profile (str): %(doc_profile)s 658 @param profile: %(doc_profile)s
649 @return (D(list)): list of message data as in [message_new] 659 @return: list of message data as in [message_new]
650 """ 660 """
651 assert profile != C.PROF_KEY_NONE 661 assert profile != C.PROF_KEY_NONE
652 if limit == C.HISTORY_LIMIT_DEFAULT: 662 if limit == C.HISTORY_LIMIT_DEFAULT:
653 limit = int(self.param_get_a(C.HISTORY_LIMIT, "General", profile_key=profile)) 663 limit = int(self.param_get_a(C.HISTORY_LIMIT, "General", profile_key=profile))
654 elif limit == C.HISTORY_LIMIT_NONE: 664 elif limit == C.HISTORY_LIMIT_NONE: