comparison src/memory/memory.py @ 2013:b536dd121da1

backend (memory), frontends: improved history filtering: a "filters" dictionnary is now use to filter, it can have, for now, filtering on: - "body": filter only on the body (equivalent to former "search" parameter, but not case sensitive) - "search": fitler on body + source resource - "types": allowed types - "not_types": forbidden types primitivus now do searching using "search", i.e. source resource is now taken into account (and search is now case insensitive)
author Goffi <goffi@goffi.org>
date Mon, 18 Jul 2016 00:52:02 +0200
parents 200cd707a46d
children d44efd32bc2f
comparison
equal deleted inserted replaced
2012:53587e738aca 2013:b536dd121da1
511 ## History ## 511 ## History ##
512 512
513 def addToHistory(self, client, data): 513 def addToHistory(self, client, data):
514 return self.storage.addToHistory(data, client.profile) 514 return self.storage.addToHistory(data, client.profile)
515 515
516 def _historyGet(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE): 516 def _historyGet(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True, filters=None, profile=C.PROF_KEY_NONE):
517 return self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between, search, profile) 517 return self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between, filters, profile)
518 518
519 def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE): 519 def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, filters=None, profile=C.PROF_KEY_NONE):
520 """Retrieve messages in history 520 """Retrieve messages in history
521 521
522 @param from_jid (JID): source JID (full, or bare for catchall) 522 @param from_jid (JID): source JID (full, or bare for catchall)
523 @param to_jid (JID): dest JID (full, or bare for catchall) 523 @param to_jid (JID): dest JID (full, or bare for catchall)
524 @param limit (int): maximum number of messages to get: 524 @param limit (int): maximum number of messages to get:
525 - 0 for no message (returns the empty list) 525 - 0 for no message (returns the empty list)
526 - C.HISTORY_LIMIT_NONE or None for unlimited 526 - C.HISTORY_LIMIT_NONE or None for unlimited
527 - C.HISTORY_LIMIT_DEFAULT to use the HISTORY_LIMIT parameter value 527 - C.HISTORY_LIMIT_DEFAULT to use the HISTORY_LIMIT parameter value
528 @param between (bool): confound source and dest (ignore the direction) 528 @param between (bool): confound source and dest (ignore the direction)
529 @param search (str): pattern to filter the history results 529 @param filters (str): pattern to filter the history results (see bridge API for details)
530 @param profile (str): %(doc_profile)s 530 @param profile (str): %(doc_profile)s
531 @return (D(list)): list of message data as in [messageNew] 531 @return (D(list)): list of message data as in [messageNew]
532 """ 532 """
533 assert profile != C.PROF_KEY_NONE 533 assert profile != C.PROF_KEY_NONE
534 if limit == C.HISTORY_LIMIT_DEFAULT: 534 if limit == C.HISTORY_LIMIT_DEFAULT:
535 limit = int(self.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile)) 535 limit = int(self.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile))
536 elif limit == C.HISTORY_LIMIT_NONE: 536 elif limit == C.HISTORY_LIMIT_NONE:
537 limit = None 537 limit = None
538 if limit == 0: 538 if limit == 0:
539 return defer.succeed([]) 539 return defer.succeed([])
540 return self.storage.historyGet(from_jid, to_jid, limit, between, search, profile) 540 return self.storage.historyGet(from_jid, to_jid, limit, between, filters, profile)
541 541
542 ## Statuses ## 542 ## Statuses ##
543 543
544 def _getPresenceStatuses(self, profile_key): 544 def _getPresenceStatuses(self, profile_key):
545 ret = self.getPresenceStatuses(profile_key) 545 ret = self.getPresenceStatuses(profile_key)