Commit 0c33075e authored by Philipp Hörist's avatar Philipp Hörist

DiscoInfo: Add stanza attribute

Make stanza object available in DiscoInfo and derive some propertys from it
parent ecfed11e
......@@ -89,8 +89,7 @@ def parse_disco_info(stanza):
for node in query.getTags('x', namespace=NS_DATA):
dataforms.append(extend_form(node))
return DiscoInfo(jid=stanza.getFrom(),
node=query.getAttr('node'),
return DiscoInfo(stanza=stanza,
identities=idenities,
features=features,
dataforms=dataforms)
......
......@@ -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):
......@@ -150,6 +150,24 @@ class DiscoInfo(namedtuple('DiscoInfo', 'jid node identities features dataforms'
def supports(self, feature):
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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment