summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-03-23 17:04:47 +0000
committerMaxime “pep” Buquet <pep@bouah.net>2019-03-23 17:06:07 +0000
commit2dda6b80d46e2d07175348777db69f58b7735ac3 (patch)
tree735e55dded7f52d6dccb7fd418b843cbe0ebaee5
parent5629e44710cb1b75fdd8d71ad7c8f8dc94a81304 (diff)
downloadslixmpp-2dda6b80d46e2d07175348777db69f58b7735ac3.tar.gz
slixmpp-2dda6b80d46e2d07175348777db69f58b7735ac3.tar.bz2
slixmpp-2dda6b80d46e2d07175348777db69f58b7735ac3.tar.xz
slixmpp-2dda6b80d46e2d07175348777db69f58b7735ac3.zip
Partially fix poezio/poezio#3452. Prevent `groupchat_subject` from triggered sent when body or thread are in the message.
0045 says: > The subject is changed by sending a message of type "groupchat" to the > <room@service>, where the <message/> MUST contain a <subject/> element that > specifies the new subject but MUST NOT contain a <body/> element (or a > <thread/> element). In accordance with the core definition of XMPP, other child > elements are allowed (although the entity that receives them might ignore > them). > > Note: A message with a <subject/> and a <body/> or a <subject/> and a <thread/> > is a legitimate message, but it SHALL NOT be interpreted as a subject change. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--slixmpp/plugins/xep_0045.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0045.py b/slixmpp/plugins/xep_0045.py
index 3d910316..83521b01 100644
--- a/slixmpp/plugins/xep_0045.py
+++ b/slixmpp/plugins/xep_0045.py
@@ -9,7 +9,7 @@ from __future__ import with_statement
import logging
-from slixmpp import Presence
+from slixmpp import Presence, Message
from slixmpp.plugins import BasePlugin, register_plugin
from slixmpp.xmlstream import register_stanza_plugin, ElementBase, JID, ET
from slixmpp.xmlstream.handler.callback import Callback
@@ -181,7 +181,7 @@ class XEP_0045(BasePlugin):
if got_online:
self.xmpp.event("muc::%s::got_online" % entry['room'], pr)
- def handle_groupchat_message(self, msg):
+ def handle_groupchat_message(self, msg: Message) -> None:
""" Handle a message event in a muc.
"""
self.xmpp.event('groupchat_message', msg)
@@ -195,10 +195,14 @@ class XEP_0045(BasePlugin):
- def handle_groupchat_subject(self, msg):
+ def handle_groupchat_subject(self, msg: Message) -> None:
""" Handle a message coming from a muc indicating
a change of subject (or announcing it when joining the room)
"""
+ # See poezio#3452. A message containing subject _and_ (body or thread)
+ # is not a subject change.
+ if msg['body'] or msg['thread']:
+ return None
self.xmpp.event('groupchat_subject', msg)
def jid_in_room(self, room, jid):