Detect invalid user activity
This commit is contained in:
parent
7c7df9d4a4
commit
3e362874be
|
@ -65,6 +65,9 @@ class UserActivity(AbstractPEPModule):
|
||||||
if activity_tag is None:
|
if activity_tag is None:
|
||||||
raise StanzaMalformed('No activity node')
|
raise StanzaMalformed('No activity node')
|
||||||
|
|
||||||
|
if not activity_tag.getChildren():
|
||||||
|
return None
|
||||||
|
|
||||||
for child in activity_tag.getChildren():
|
for child in activity_tag.getChildren():
|
||||||
name = child.getName().strip()
|
name = child.getName().strip()
|
||||||
data = child.getData().strip()
|
data = child.getData().strip()
|
||||||
|
@ -76,17 +79,22 @@ class UserActivity(AbstractPEPModule):
|
||||||
subactivity_name = subactivity.getName().strip()
|
subactivity_name = subactivity.getName().strip()
|
||||||
activity_dict['subactivity'] = subactivity_name
|
activity_dict['subactivity'] = subactivity_name
|
||||||
|
|
||||||
return activity_dict or None
|
if 'activity' not in activity_dict:
|
||||||
|
raise StanzaMalformed('No activity value found')
|
||||||
|
return activity_dict
|
||||||
|
|
||||||
def _build_node(self, data):
|
def _build_node(self, data):
|
||||||
item = nbxmpp.Node('activity', {'xmlns': self.namespace})
|
item = nbxmpp.Node('activity', {'xmlns': self.namespace})
|
||||||
if data is None:
|
if data is None:
|
||||||
return item
|
return item
|
||||||
|
|
||||||
activity, subactivity, message = data
|
activity, subactivity, message = data
|
||||||
if activity:
|
if not activity:
|
||||||
i = item.addChild(activity)
|
return item
|
||||||
if subactivity:
|
|
||||||
i.addChild(subactivity)
|
i = item.addChild(activity)
|
||||||
|
if subactivity:
|
||||||
|
i.addChild(subactivity)
|
||||||
if message:
|
if message:
|
||||||
i = item.addChild('text')
|
i = item.addChild('text')
|
||||||
i.addData(message)
|
i.addData(message)
|
||||||
|
|
Loading…
Reference in New Issue