# HG changeset patch # User Goffi # Date 1623332670 -7200 # Node ID 4dad134a82c69c7e54d2cd326fdf2e85e2b85a5c # Parent 413e96caa682eeeea7e6095adf082518c58e0852 plugin XEP-0313: on cold start (without known archive) we only request 50 last messages diff -r 413e96caa682 -r 4dad134a82c6 sat/plugins/plugin_xep_0313.py --- 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: