plugin XEP-0045: don't loop when initiating MAM archive

This commit is contained in:
Goffi 2018-12-12 08:58:52 +01:00
commit bea35db274

View file

@ -871,12 +871,14 @@ class SatMUCClient(muc.MUCClient):
if last_mess:
stanza_id = last_mess[0][-1][u'stanza_id']
rsm_req = rsm.RSMRequest(max_=100, after=stanza_id)
no_loop=False
else:
log.info(u"We have no MAM archive for room {room_jid}.".format(
room_jid=room_jid))
# we don't want the whole archive if we have no archive yet
# as it can be huge
rsm_req = rsm.RSMRequest(max_=50, before=u'')
no_loop=True
mam_req = mam.MAMRequest(rsm_=rsm_req)
complete = False
@ -885,7 +887,7 @@ class SatMUCClient(muc.MUCClient):
mam_data = yield self._mam.getArchives(client, mam_req,
service=room_jid)
elt_list, rsm_response, mam_response = mam_data
complete = mam_response[u"complete"]
complete = True if no_loop else mam_response[u"complete"]
# we update MAM request for next iteration
mam_req.rsm.after = rsm_response.last