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

@ -278,18 +278,18 @@ class QuickChat(quick_widgets.QuickWidget):
return True
return False
def updateHistory(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'):
def updateHistory(self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile='@NONE@'):
"""Called when history need to be recreated
Remove all message from history then call historyPrint
Must probably be overriden by frontend to clear widget
@param size (int): number of messages
@param search (str): pattern to filter the history results
@param filters (str): patterns to filter the history results
@param profile (str): %(doc_profile)s
"""
self._locked = True
self.messages.clear()
self.historyPrint(size, search, profile)
self.historyPrint(size, filters, profile)
def _onHistoryPrinted(self):
"""Method called when history is printed (or failed)
@ -301,13 +301,15 @@ class QuickChat(quick_widgets.QuickWidget):
for data in self._cache:
self.messageNew(*data)
def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'):
def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile='@NONE@'):
"""Print the current history
@param size (int): number of messages
@param search (str): pattern to filter the history results
@param profile (str): %(doc_profile)s
"""
if filters is None:
filters = {}
if size == 0:
log.debug(u"Empty history requested, skipping")
self._onHistoryPrinted()
@ -340,7 +342,7 @@ class QuickChat(quick_widgets.QuickWidget):
log.error(_(u"Can't get history"))
self._onHistoryPrinted()
self.host.bridge.historyGet(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, search, profile, callback=_historyGetCb, errback=_historyGetEb)
self.host.bridge.historyGet(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, filters, profile, callback=_historyGetCb, errback=_historyGetEb)
def messageNew(self, uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile):
log.debug(u"messageNew ==> {}".format((uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile)))