Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0313.py @ 3561:4dad134a82c6
plugin XEP-0313: on cold start (without known archive) we only request 50 last messages
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 10 Jun 2021 15:44:30 +0200 |
parents | be6d91572633 |
children | 813595f88612 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0313.py Thu Jun 10 15:43:28 2021 +0200 +++ b/sat/plugins/plugin_xep_0313.py Thu Jun 10 15:44:30 2021 +0200 @@ -81,6 +81,7 @@ 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 @@ 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 @@ 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: