bridge, memory: add "search" attribute to getHistory (filter the results with a unix globbing pattern)

This commit is contained in:
souliane 2014-10-04 10:25:32 +02:00
commit 767f3d50dc
6 changed files with 22 additions and 13 deletions

View file

@ -350,7 +350,7 @@ class Memory(object):
extra = {}
return self.storage.addToHistory(from_jid, to_jid, message, type_, extra, timestamp, profile)
def getHistory(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, profile=C.PROF_KEY_NONE):
def getHistory(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE):
"""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)
@ -359,6 +359,7 @@ class Memory(object):
- 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 search (str): pattern to filter the history results
@param profile (str): %(doc_profile)s
@return: list of tuple as in http://wiki.goffi.org/wiki/Bridge_API#getHistory
"""
@ -369,7 +370,7 @@ class Memory(object):
limit = None
if limit == 0:
return defer.succeed([])
return self.storage.getHistory(jid.JID(from_jid), jid.JID(to_jid), limit, between, profile)
return self.storage.getHistory(jid.JID(from_jid), jid.JID(to_jid), limit, between, search, profile)
def _getLastResource(self, jid_s, profile_key):
jid_ = jid.JID(jid_s)