Commit eaf87138 authored by Link Mauve's avatar Link Mauve

Checks whether the gaming payload is empty or not

Fixes a long-standing bug where a gaming stop event would be interpreted
as starting a game.

Also does the same for mood, activity and tune.
parent dbef6f43
...@@ -557,7 +557,9 @@ class HandlerCore: ...@@ -557,7 +557,9 @@ class HandlerCore:
return return
item = message['pubsub_event']['items']['item'] item = message['pubsub_event']['items']['item']
old_gaming = contact.gaming old_gaming = contact.gaming
if item.xml.find('{urn:xmpp:gaming:0}game') is not None: xml_node = item.xml.find('{urn:xmpp:gaming:0}game')
# list(xml_node) checks whether there are children or not.
if xml_node is not None and list(xml_node):
item = item['gaming'] item = item['gaming']
# only name and server_address are used for now # only name and server_address are used for now
contact.gaming = { contact.gaming = {
...@@ -599,7 +601,9 @@ class HandlerCore: ...@@ -599,7 +601,9 @@ class HandlerCore:
roster.modified() roster.modified()
item = message['pubsub_event']['items']['item'] item = message['pubsub_event']['items']['item']
old_mood = contact.mood old_mood = contact.mood
if item.xml.find('{http://jabber.org/protocol/mood}mood') is not None: xml_node = item.xml.find('{http://jabber.org/protocol/mood}mood')
# list(xml_node) checks whether there are children or not.
if xml_node is not None and list(xml_node):
mood = item['mood']['value'] mood = item['mood']['value']
if mood: if mood:
mood = pep.MOODS.get(mood, mood) mood = pep.MOODS.get(mood, mood)
...@@ -637,8 +641,9 @@ class HandlerCore: ...@@ -637,8 +641,9 @@ class HandlerCore:
roster.modified() roster.modified()
item = message['pubsub_event']['items']['item'] item = message['pubsub_event']['items']['item']
old_activity = contact.activity old_activity = contact.activity
if item.xml.find( xml_node = item.xml.find('{http://jabber.org/protocol/activity}activity')
'{http://jabber.org/protocol/activity}activity') is not None: # list(xml_node) checks whether there are children or not.
if xml_node is not None and list(xml_node):
try: try:
activity = item['activity']['value'] activity = item['activity']['value']
except ValueError: except ValueError:
...@@ -683,7 +688,9 @@ class HandlerCore: ...@@ -683,7 +688,9 @@ class HandlerCore:
roster.modified() roster.modified()
item = message['pubsub_event']['items']['item'] item = message['pubsub_event']['items']['item']
old_tune = contact.tune old_tune = contact.tune
if item.xml.find('{http://jabber.org/protocol/tune}tune') is not None: xml_node = item.xml.find('{http://jabber.org/protocol/tune}tune')
# list(xml_node) checks whether there are children or not.
if xml_node is not None and list(xml_node):
item = item['tune'] item = item['tune']
contact.tune = { contact.tune = {
'artist': item['artist'], 'artist': item['artist'],
......
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