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)
This commit is contained in:
Goffi 2016-07-18 00:52:02 +02:00
commit 9647e90943

View file

@ -513,10 +513,10 @@ class Memory(object):
def addToHistory(self, client, data):
return self.storage.addToHistory(data, client.profile)
def _historyGet(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE):
return self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between, search, profile)
def _historyGet(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True, filters=None, profile=C.PROF_KEY_NONE):
return self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between, filters, profile)
def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE):
def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, filters=None, profile=C.PROF_KEY_NONE):
"""Retrieve messages in history
@param from_jid (JID): source JID (full, or bare for catchall)
@ -526,7 +526,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 filters (str): 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 [messageNew]
"""
@ -537,7 +537,7 @@ class Memory(object):
limit = None
if limit == 0:
return defer.succeed([])
return self.storage.historyGet(from_jid, to_jid, limit, between, search, profile)
return self.storage.historyGet(from_jid, to_jid, limit, between, filters, profile)
## Statuses ##