summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-09 19:15:27 +0100
committermathieui <mathieui@mathieui.net>2021-03-09 19:52:53 +0100
commite329eadbedf3dada89f3e7fd5e2bf5d24e995f27 (patch)
treed64922d39f462963478a10fa6aabbb68a8e71a93
parent4cdcc4d155d1bd11afb6366f2b5efa1739788d01 (diff)
downloadslixmpp-e329eadbedf3dada89f3e7fd5e2bf5d24e995f27.tar.gz
slixmpp-e329eadbedf3dada89f3e7fd5e2bf5d24e995f27.tar.bz2
slixmpp-e329eadbedf3dada89f3e7fd5e2bf5d24e995f27.tar.xz
slixmpp-e329eadbedf3dada89f3e7fd5e2bf5d24e995f27.zip
XEP-0313: Fix off-by-one-page RSM fetching
Add a "results" interface to mam_fin, and fix some things in RSM Items just received were not taken into account because: - RSM code is checking iq['mam_fin']['results'], results were at iq['mam']['results'] - RSM handler was run after checking the number
-rw-r--r--slixmpp/plugins/xep_0059/rsm.py6
-rw-r--r--slixmpp/plugins/xep_0313/mam.py2
-rw-r--r--slixmpp/plugins/xep_0313/stanza.py18
3 files changed, 23 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0059/rsm.py b/slixmpp/plugins/xep_0059/rsm.py
index 61752af4..085ee474 100644
--- a/slixmpp/plugins/xep_0059/rsm.py
+++ b/slixmpp/plugins/xep_0059/rsm.py
@@ -135,6 +135,9 @@ class ResultIterator(AsyncIterator):
not r[self.recv_interface]['rsm']['last']:
raise StopAsyncIteration
+ if self.post_cb:
+ self.post_cb(r)
+
if r[self.recv_interface]['rsm']['count'] and \
r[self.recv_interface]['rsm']['first_index']:
count = int(r[self.recv_interface]['rsm']['count'])
@@ -147,9 +150,6 @@ class ResultIterator(AsyncIterator):
self.start = r[self.recv_interface]['rsm']['first']
else:
self.start = r[self.recv_interface]['rsm']['last']
-
- if self.post_cb:
- self.post_cb(r)
return r
except XMPPError:
raise StopAsyncIteration
diff --git a/slixmpp/plugins/xep_0313/mam.py b/slixmpp/plugins/xep_0313/mam.py
index c06360c4..cc3b1958 100644
--- a/slixmpp/plugins/xep_0313/mam.py
+++ b/slixmpp/plugins/xep_0313/mam.py
@@ -112,6 +112,7 @@ class XEP_0313(BasePlugin):
results = cb_data['collector'].stop()
if result['type'] == 'result':
result['mam']['results'] = results
+ result['mam_fin']['results'] = results
if iterator:
return self.xmpp['xep_0059'].iterate(
@@ -185,6 +186,7 @@ class XEP_0313(BasePlugin):
results = cb_data['collector'].stop()
if result['type'] == 'result':
result['mam']['results'] = results
+ result['mam_fin']['results'] = results
iterator = self.xmpp['xep_0059'].iterate(
iq, 'mam', 'results', amount=amount,
diff --git a/slixmpp/plugins/xep_0313/stanza.py b/slixmpp/plugins/xep_0313/stanza.py
index fbca3c8e..6633717f 100644
--- a/slixmpp/plugins/xep_0313/stanza.py
+++ b/slixmpp/plugins/xep_0313/stanza.py
@@ -187,6 +187,24 @@ class Fin(ElementBase):
name = 'fin'
namespace = 'urn:xmpp:mam:2'
plugin_attrib = 'mam_fin'
+ interfaces = {'results'}
+
+ def setup(self, xml=None):
+ ElementBase.setup(self, xml)
+ self._results: List[Message] = []
+
+ # The results interface is meant only as an easy
+ # way to access the set of collected message responses
+ # from the query.
+
+ def get_results(self) -> List[Message]:
+ return self._results
+
+ def set_results(self, values: List[Message]):
+ self._results = values
+
+ def del_results(self):
+ self._results = []
class Result(ElementBase):