summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-07-16 22:39:36 +0200
committermathieui <mathieui@mathieui.net>2013-08-04 14:50:58 +0200
commitd01f6208d67f6c88584fc1f362dae0a9f2d107d0 (patch)
treef68a0dbd75aa9aa7a557e64811d3470448011116
parent149687613614553865887167d793e1dd375841bc (diff)
downloadpoezio-d01f6208d67f6c88584fc1f362dae0a9f2d107d0.tar.gz
poezio-d01f6208d67f6c88584fc1f362dae0a9f2d107d0.tar.bz2
poezio-d01f6208d67f6c88584fc1f362dae0a9f2d107d0.tar.xz
poezio-d01f6208d67f6c88584fc1f362dae0a9f2d107d0.zip
If plugins removed the message body in a callback, don’t send it
-rw-r--r--src/core.py2
-rw-r--r--src/tabs.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/src/core.py b/src/core.py
index 22bc0044..9de53b51 100644
--- a/src/core.py
+++ b/src/core.py
@@ -2885,6 +2885,8 @@ class Core(object):
conversation.nick = remote_nick
self.events.trigger('conversation_msg', message, conversation)
+ if not message['body']:
+ return
body = xhtml.get_body_from_message_stanza(message)
delayed, date = common.find_delayed_tag(message)
diff --git a/src/tabs.py b/src/tabs.py
index 80182a52..e5564aa6 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1240,6 +1240,8 @@ class MucTab(ChatTab):
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
self.core.events.trigger('muc_say', msg, self)
+ if not msg['body']:
+ return
if msg['body'].find('\x19') != -1:
msg.enable('html')
msg['html']['body'] = xhtml.poezio_colors_to_html(msg['body'])
@@ -1250,6 +1252,8 @@ class MucTab(ChatTab):
msg['replace']['id'] = self.last_sent_message['id']
self.cancel_paused_delay()
self.core.events.trigger('muc_say_after', msg, self)
+ if not msg['body']:
+ return
self.last_sent_message = msg
msg.send()
self.chat_state = needed
@@ -1908,6 +1912,8 @@ class PrivateTab(ChatTab):
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
self.core.events.trigger('private_say', msg, self)
+ if not msg['body']:
+ return
user = self.parent_muc.get_user_by_name(self.own_nick)
replaced = False
if correct:
@@ -1938,6 +1944,8 @@ class PrivateTab(ChatTab):
if attention and self.remote_supports_attention:
msg['attention'] = True
self.core.events.trigger('private_say_after', msg, self)
+ if not msg['body']:
+ return
self.last_sent_message = msg
msg.send()
self.cancel_paused_delay()
@@ -3100,6 +3108,8 @@ class ConversationTab(ChatTab):
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
self.core.events.trigger('conversation_say', msg, self)
+ if not msg['body']:
+ return
replaced = False
if correct:
msg['replace']['id'] = self.last_sent_message['id']
@@ -3127,6 +3137,8 @@ class ConversationTab(ChatTab):
if attention and self.remote_supports_attention:
msg['attention'] = True
self.core.events.trigger('conversation_say_after', msg, self)
+ if not msg['body']:
+ return
self.last_sent_message = msg
msg.send()
self.cancel_paused_delay()