diff options
author | mathieui <mathieui@mathieui.net> | 2019-09-10 23:13:04 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2019-09-10 23:13:04 +0200 |
commit | e58988484a03016df1a331d1389f03a0e7e1bb43 (patch) | |
tree | 832ce5819660c134d2d81fc61ef2691580cbd28f | |
parent | 5d5e5cda1917eb0404df3ba6173962078064c7f2 (diff) | |
download | slixmpp-e58988484a03016df1a331d1389f03a0e7e1bb43.tar.gz slixmpp-e58988484a03016df1a331d1389f03a0e7e1bb43.tar.bz2 slixmpp-e58988484a03016df1a331d1389f03a0e7e1bb43.tar.xz slixmpp-e58988484a03016df1a331d1389f03a0e7e1bb43.zip |
Match the sender JID as well as the queryid in MAM results
-rw-r--r-- | slixmpp/plugins/xep_0313/mam.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0313/mam.py b/slixmpp/plugins/xep_0313/mam.py index d407e2bf..da9ed17b 100644 --- a/slixmpp/plugins/xep_0313/mam.py +++ b/slixmpp/plugins/xep_0313/mam.py @@ -14,7 +14,7 @@ from typing import Any, Dict, Callable, Optional, Awaitable from slixmpp import JID from slixmpp.stanza import Message, Iq from slixmpp.xmlstream.handler import Collector -from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.xmlstream.matcher import MatchXMLMask from slixmpp.xmlstream import register_stanza_plugin from slixmpp.plugins import BasePlugin from slixmpp.plugins.xep_0313 import stanza @@ -87,11 +87,21 @@ class XEP_0313(BasePlugin): amount = value cb_data = {} + stanza_mask = self.xmpp.Message() + stanza_mask.xml.remove(stanza_mask.xml.find('{urn:xmpp:sid:0}origin-id')) + del stanza_mask['id'] + del stanza_mask['lang'] + stanza_mask['from'] = jid + stanza_mask['mam_result']['queryid'] = query_id + xml_mask = str(stanza_mask) + def pre_cb(query: Iq) -> None: + stanza_mask['mam_result']['queryid'] = query['id'] + xml_mask = str(stanza_mask) query['mam']['queryid'] = query['id'] collector = Collector( 'MAM_Results_%s' % query_id, - StanzaPath('message/mam_result@queryid=%s' % query['id'])) + MatchXMLMask(xml_mask)) self.xmpp.register_handler(collector) cb_data['collector'] = collector @@ -107,7 +117,7 @@ class XEP_0313(BasePlugin): collector = Collector( 'MAM_Results_%s' % query_id, - StanzaPath('message/mam_result@queryid=%s' % query_id)) + MatchXMLMask(xml_mask)) self.xmpp.register_handler(collector) def wrapped_cb(iq: Iq) -> None: |