summaryrefslogtreecommitdiff
path: root/slixmpp
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2020-05-27 22:36:28 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2020-05-27 22:39:52 +0200
commit07b1a4c1cdbf8c7f8ea1d0771501d2a9cc2eb2a9 (patch)
tree00cbfc826f1e99674fd6b25dcff5c0d632b371f5 /slixmpp
parentcec34686fcfe09281931e977fcf322dac275aad1 (diff)
downloadslixmpp-07b1a4c1cdbf8c7f8ea1d0771501d2a9cc2eb2a9.tar.gz
slixmpp-07b1a4c1cdbf8c7f8ea1d0771501d2a9cc2eb2a9.tar.bz2
slixmpp-07b1a4c1cdbf8c7f8ea1d0771501d2a9cc2eb2a9.tar.xz
slixmpp-07b1a4c1cdbf8c7f8ea1d0771501d2a9cc2eb2a9.zip
XEP-0421: add has_feature helper
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'slixmpp')
-rw-r--r--slixmpp/plugins/xep_0421/occupant_id.py8
-rw-r--r--slixmpp/plugins/xep_0421/stanza.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0421/occupant_id.py b/slixmpp/plugins/xep_0421/occupant_id.py
index 51d374fc..ff7fcda5 100644
--- a/slixmpp/plugins/xep_0421/occupant_id.py
+++ b/slixmpp/plugins/xep_0421/occupant_id.py
@@ -6,7 +6,7 @@
See the file LICENSE for copying permission.
"""
-from slixmpp import Message
+from slixmpp import JID, Message
from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins.xep_0421 import stanza
@@ -18,9 +18,13 @@ class XEP_0421(BasePlugin):
name = 'xep_0421'
description = 'Anonymous unique occupant identifiers for MUCs'
- dependencies = {'xep_0045'}
+ dependencies = {'xep_0030', 'xep_0045'}
stanza = stanza
def plugin_init(self) -> None:
# XXX: This should be MucMessage. Someday..
register_stanza_plugin(Message, OccupantId)
+
+ async def has_feature(self, jid: JID) -> bool:
+ info = await self.xmpp['xep_0030'].get_info(jid)
+ return self.stanza.NS in info.get_features()
diff --git a/slixmpp/plugins/xep_0421/stanza.py b/slixmpp/plugins/xep_0421/stanza.py
index d05bcfc1..0cb93959 100644
--- a/slixmpp/plugins/xep_0421/stanza.py
+++ b/slixmpp/plugins/xep_0421/stanza.py
@@ -9,6 +9,9 @@
from slixmpp.xmlstream import ElementBase
+NS = 'urn:xmpp:occupant-id:0'
+
+
class OccupantId(ElementBase):
'''
An Occupant-id tag.
@@ -33,5 +36,5 @@ class OccupantId(ElementBase):
'''
name = 'occupant-id'
- namespace = 'urn:xmpp:occupant-id:0'
+ namespace = NS
interface = {'id'}