From 2dda6b80d46e2d07175348777db69f58b7735ac3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?=
Date: Sat, 23 Mar 2019 17:04:47 +0000
Subject: Partially fix poezio/poezio#3452. Prevent `groupchat_subject` from
triggered sent when body or thread are in the message.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
0045 says:
> The subject is changed by sending a message of type "groupchat" to the
> , where the MUST contain a element that
> specifies the new subject but MUST NOT contain a element (or a
> 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 and a or a and a
> is a legitimate message, but it SHALL NOT be interpreted as a subject change.
Signed-off-by: Maxime “pep” Buquet
---
slixmpp/plugins/xep_0045.py | 10 +++++++---
1 file 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):
--
cgit v1.2.3