memory: add Parameter "Chat history limit"
This commit is contained in:
parent
4c61bf8fad
commit
4f339272b7
1 changed files with 50 additions and 18 deletions
|
|
@ -350,8 +350,25 @@ 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=None, between=True, profile=C.PROF_KEY_NONE):
|
||||
def getHistory(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, 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)
|
||||
@param limit (int): maximum number of messages to get:
|
||||
- 0 for no message (returns the empty list)
|
||||
- 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 profile (str): %(doc_profile)s
|
||||
@return: list of tuple as in http://wiki.goffi.org/wiki/Bridge_API#getHistory
|
||||
"""
|
||||
assert profile != C.PROF_KEY_NONE
|
||||
if limit == C.HISTORY_LIMIT_DEFAULT:
|
||||
limit = int(self.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile))
|
||||
elif limit == C.HISTORY_LIMIT_NONE:
|
||||
limit = None
|
||||
if limit == 0:
|
||||
return defer.succeed([])
|
||||
return self.storage.getHistory(jid.JID(from_jid), jid.JID(to_jid), limit, between, profile)
|
||||
|
||||
def _getLastResource(self, jid_s, profile_key):
|
||||
|
|
|
|||
Loading…
Reference in a new issue