bridge, memory: add "search" attribute to getHistory (filter the results with a unix globbing pattern)
This commit is contained in:
parent
7a344fcf5d
commit
767f3d50dc
6 changed files with 22 additions and 13 deletions
|
|
@ -264,7 +264,7 @@ class SqliteStorage(object):
|
|||
{"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message})))
|
||||
return d
|
||||
|
||||
def getHistory(self, from_jid, to_jid, limit=None, between=True, profile=None):
|
||||
def getHistory(self, from_jid, to_jid, limit=None, between=True, search=None, profile=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)
|
||||
|
|
@ -272,6 +272,7 @@ class SqliteStorage(object):
|
|||
- 0 for no message (returns the empty list)
|
||||
- None for unlimited
|
||||
@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
|
||||
"""
|
||||
|
|
@ -311,6 +312,10 @@ class SqliteStorage(object):
|
|||
else:
|
||||
query_parts.append("%s AND %s" % (test_jid('source', from_jid),
|
||||
test_jid('dest', to_jid)))
|
||||
if search:
|
||||
# TODO: use REGEXP (function to be defined) instead of GLOB: https://www.sqlite.org/lang_expr.html
|
||||
query_parts.append("AND message GLOB ?")
|
||||
values.append("*%s*" % search)
|
||||
|
||||
query_parts.append("ORDER BY timestamp DESC")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue