memory: getHistory with limit=0 now returns an empty list, use limit=None to return all messages

This commit is contained in:
souliane 2014-10-03 12:43:59 +02:00
commit 4c61bf8fad
2 changed files with 6 additions and 4 deletions

View file

@ -264,13 +264,15 @@ 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=0, between=True, profile=None):
def getHistory(self, from_jid, to_jid, limit=None, between=True, profile=None):
"""Store a new message in history
@param from_jid: source JID (full, or bare for catchall
@param to_jid: dest JID (full, or bare for catchall
@param size: maximum number of messages to get, or 0 for unlimited
@param size: maximum number of messages to get, or None for unlimited
"""
assert(profile)
if limit == 0:
return defer.succeed([])
def sqliteToList(query_result):
query_result.reverse()
@ -307,7 +309,7 @@ class SqliteStorage(object):
query_parts.append("ORDER BY timestamp DESC")
if limit:
if limit is not None:
query_parts.append("LIMIT ?")
values.append(limit)