changeset 2724:35a0ab3032bb

plugin XEP-0045: don't loop when initiating MAM archive
author Goffi <goffi@goffi.org>
date Wed, 12 Dec 2018 08:58:52 +0100
parents c6be5962752d
children d0466af33483
files sat/plugins/plugin_xep_0045.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0045.py	Wed Dec 12 01:13:15 2018 +0100
+++ b/sat/plugins/plugin_xep_0045.py	Wed Dec 12 08:58:52 2018 +0100
@@ -871,12 +871,14 @@
         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 @@
             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