Dont fail on malformed pubsub events

This commit is contained in:
Philipp Hörist 2019-02-01 17:03:46 +01:00
parent b9b9dae6a0
commit 0b6fac44dc
3 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,8 @@ class UserActivity(BaseModule):
@event_node(nbxmpp.NS_ACTIVITY)
def _activity_received(self, _con, _stanza, properties):
data = properties.pubsub_event.data
if data is None:
return
for contact in app.contacts.get_contacts(self._account,
str(properties.jid)):
if data.activity is not None:

View File

@ -45,6 +45,8 @@ class UserMood(BaseModule):
@event_node(nbxmpp.NS_MOOD)
def _mood_received(self, _con, _stanza, properties):
data = properties.pubsub_event.data
if data is None:
return
for contact in app.contacts.get_contacts(self._account,
str(properties.jid)):
if data.mood is not None:

View File

@ -55,6 +55,8 @@ def event_node(node):
def event_node_decorator(func):
@wraps(func)
def func_wrapper(self, _con, _stanza, properties):
if not properties.is_pubsub_event:
return
if properties.pubsub_event.node != node:
return
func(self, _con, _stanza, properties)