plugin XEP-0313: on cold start (without known archive) we only request 50 last messages
This commit is contained in:
parent
7e622ae5d1
commit
6426103f12
1 changed files with 6 additions and 2 deletions
|
|
@ -81,6 +81,7 @@ class XEP_0313(object):
|
|||
stanza_id_data = yield self.host.memory.storage.getPrivates(
|
||||
mam.NS_MAM, [KEY_LAST_STANZA_ID], profile=client.profile)
|
||||
stanza_id = stanza_id_data.get(KEY_LAST_STANZA_ID)
|
||||
rsm_req = None
|
||||
if stanza_id is None:
|
||||
log.info("can't retrieve last stanza ID, checking history")
|
||||
last_mess = yield self.host.memory.historyGet(
|
||||
|
|
@ -90,10 +91,11 @@ class XEP_0313(object):
|
|||
if not last_mess:
|
||||
log.info(_("It seems that we have no MAM history yet"))
|
||||
stanza_id = None
|
||||
# FIXME: we should restrict starting of the archive, as it can be huge
|
||||
rsm_req = rsm.RSMRequest(max_=50, before="")
|
||||
else:
|
||||
stanza_id = last_mess[0][-1]['stanza_id']
|
||||
rsm_req = rsm.RSMRequest(max_=100, after=stanza_id)
|
||||
if rsm_req is None:
|
||||
rsm_req = rsm.RSMRequest(max_=100, after=stanza_id)
|
||||
mam_req = mam.MAMRequest(rsm_=rsm_req)
|
||||
complete = False
|
||||
count = 0
|
||||
|
|
@ -104,6 +106,8 @@ class XEP_0313(object):
|
|||
complete = mam_response["complete"]
|
||||
# we update MAM request for next iteration
|
||||
mam_req.rsm.after = rsm_response.last
|
||||
# before may be set if we had no previous history
|
||||
mam_req.rsm.before = None
|
||||
if not elt_list:
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue