summaryrefslogtreecommitdiff
path: root/poezio
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-05-24 22:10:09 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-05-24 22:15:33 +0200
commiteaf871384336f8899ccfbe597328ce9f5f97b9af (patch)
tree6a8b8ffd64c28ebed0fad767ade92196fa0bfd20 /poezio
parentdbef6f435f1788545c2e0593b53e9f22baecf16c (diff)
downloadpoezio-eaf871384336f8899ccfbe597328ce9f5f97b9af.tar.gz
poezio-eaf871384336f8899ccfbe597328ce9f5f97b9af.tar.bz2
poezio-eaf871384336f8899ccfbe597328ce9f5f97b9af.tar.xz
poezio-eaf871384336f8899ccfbe597328ce9f5f97b9af.zip
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.
Diffstat (limited to 'poezio')
-rw-r--r--poezio/core/handlers.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 445d8b74..cad4d47e 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -557,7 +557,9 @@ class HandlerCore:
return
item = message['pubsub_event']['items']['item']
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']
# only name and server_address are used for now
contact.gaming = {
@@ -599,7 +601,9 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
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']
if mood:
mood = pep.MOODS.get(mood, mood)
@@ -637,8 +641,9 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
old_activity = contact.activity
- if item.xml.find(
- '{http://jabber.org/protocol/activity}activity') is not None:
+ xml_node = item.xml.find('{http://jabber.org/protocol/activity}activity')
+ # list(xml_node) checks whether there are children or not.
+ if xml_node is not None and list(xml_node):
try:
activity = item['activity']['value']
except ValueError:
@@ -683,7 +688,9 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
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']
contact.tune = {
'artist': item['artist'],