Commit 1ec850cd authored by Philipp Hörist's avatar Philipp Hörist

Refactor parsing oob data

Adapt to nbxmpp changes
parent cdf111c5
Pipeline #4376 passed with stages
in 2 minutes and 53 seconds
...@@ -195,6 +195,8 @@ class MAM(BaseModule): ...@@ -195,6 +195,8 @@ class MAM(BaseModule):
additional_data.set_value( additional_data.set_value(
'gajim', 'user_timestamp', properties.user_timestamp) 'gajim', 'user_timestamp', properties.user_timestamp)
parse_oob(properties, additional_data)
event_attrs.update( event_attrs.update(
{'conn': self._con, {'conn': self._con,
'account': self._account, 'account': self._account,
...@@ -260,7 +262,6 @@ class MAM(BaseModule): ...@@ -260,7 +262,6 @@ class MAM(BaseModule):
return return
event.correct_id = parse_correction(event.message) event.correct_id = parse_correction(event.message)
parse_oob(event)
with_ = event.with_.getStripped() with_ = event.with_.getStripped()
if event.muc_pm: if event.muc_pm:
......
...@@ -148,6 +148,8 @@ class Message(BaseModule): ...@@ -148,6 +148,8 @@ class Message(BaseModule):
additional_data.set_value( additional_data.set_value(
'gajim', 'user_timestamp', properties.user_timestamp) 'gajim', 'user_timestamp', properties.user_timestamp)
parse_oob(properties, additional_data)
event_attr = { event_attr = {
'conn': self._con, 'conn': self._con,
'stanza': stanza, 'stanza': stanza,
...@@ -213,7 +215,6 @@ class Message(BaseModule): ...@@ -213,7 +215,6 @@ class Message(BaseModule):
'form_node': parse_form(event.stanza), 'form_node': parse_form(event.stanza),
'xhtml': parse_xhtml(event.stanza), 'xhtml': parse_xhtml(event.stanza),
} }
parse_oob(event)
for name, value in event_attr.items(): for name, value in event_attr.items():
setattr(event, name, value) setattr(event, name, value)
......
...@@ -25,18 +25,14 @@ log = logging.getLogger('gajim.c.m.misc') ...@@ -25,18 +25,14 @@ log = logging.getLogger('gajim.c.m.misc')
# XEP-0066: Out of Band Data # XEP-0066: Out of Band Data
def parse_oob(event): def parse_oob(properties, additional_data):
oob_node = event.stanza.getTag('x', namespace=nbxmpp.NS_X_OOB) if not properties.is_oob:
if oob_node is None:
return return
url = oob_node.getTagData('url') additional_data.set_value('gajim', 'oob_url', properties.oob.url)
if url is not None: if properties.oob.desc is not None:
event.additional_data.set_value('gajim', 'oob_url', url) additional_data.set_value('gajim', 'oob_desc',
properties.oob.desc)
desc = oob_node.getTagData('desc')
if desc is not None:
event.additional_data.set_value('gajim', 'oob_desc', desc)
# XEP-0308: Last Message Correction # XEP-0308: Last Message Correction
......
...@@ -94,13 +94,16 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase): ...@@ -94,13 +94,16 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
session.last_receive = time.time() session.last_receive = time.time()
additional_data = AdditionalDataDict()
parse_oob(properties, additional_data)
event_attr = { event_attr = {
'conn': self, 'conn': self,
'stanza': stanza, 'stanza': stanza,
'account': self.name, 'account': self.name,
'id_': id_, 'id_': id_,
'encrypted': False, 'encrypted': False,
'additional_data': AdditionalDataDict(), 'additional_data': additional_data,
'forwarded': False, 'forwarded': False,
'sent': False, 'sent': False,
'timestamp': time.time(), 'timestamp': time.time(),
...@@ -146,8 +149,6 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase): ...@@ -146,8 +149,6 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'stanza_id': event.unique_id 'stanza_id': event.unique_id
} }
parse_oob(event)
for name, value in event_attr.items(): for name, value in event_attr.items():
setattr(event, name, value) setattr(event, name, value)
......
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