Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2019-08-15 20:43:16 +0300
committerPhilipp Hörist <philipp@hoerist.com>2019-08-15 20:43:16 +0300
commit0c33075e34bba64aab83ab0c03588586711d5d40 (patch)
tree00ad42e009c0926b16bc603f1755395b1aad5e4b /nbxmpp/structs.py
parentecfed11e600c6e9d9be64ffd7b003f3bc80e47a5 (diff)
DiscoInfo: Add stanza attribute
Make stanza object available in DiscoInfo and derive some propertys from it
Diffstat (limited to 'nbxmpp/structs.py')
-rw-r--r--nbxmpp/structs.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py
index bf9a164..e5168f0 100644
--- a/nbxmpp/structs.py
+++ b/nbxmpp/structs.py
@@ -119,12 +119,12 @@ DiscoItem = namedtuple('DiscoItem', 'jid name node')
DiscoItem.__new__.__defaults__ = (None, None)
-class DiscoInfo(namedtuple('DiscoInfo', 'jid node identities features dataforms')):
+class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms')):
__slots__ = []
- def __new__(cls, jid, node, identities, features, dataforms):
- return super(DiscoInfo, cls).__new__(cls, jid, node, identities,
+ def __new__(cls, stanza, identities, features, dataforms):
+ return super(DiscoInfo, cls).__new__(cls, stanza, identities,
features, dataforms)
def get_caps_hash(self):
@@ -151,6 +151,24 @@ class DiscoInfo(namedtuple('DiscoInfo', 'jid node identities features dataforms'
return feature in self.features
@property
+ def node(self):
+ try:
+ query = self.stanza.getQuery()
+ except Exception:
+ return None
+
+ if query is not None:
+ return query.getAttr('node')
+ return None
+
+ @property
+ def jid(self):
+ try:
+ return self.stanza.getFrom()
+ except Exception:
+ return None
+
+ @property
def mam_namespace(self):
if NS_MAM_2 in self.features:
return NS_MAM_2