changeset 2829:649cb3fd7711

quick frontend(app): avoid sending empty messages
author Goffi <goffi@goffi.org>
date Fri, 01 Mar 2019 17:42:28 +0100
parents 08b54bf77c54
children 770ec685ff1f
files sat_frontends/quick_frontend/quick_app.py
diffstat 1 files changed, 6 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/quick_app.py	Fri Mar 01 17:33:15 2019 +0100
+++ b/sat_frontends/quick_frontend/quick_app.py	Fri Mar 01 17:42:28 2019 +0100
@@ -728,17 +728,11 @@
         for widget in self.widgets.getWidgets(quick_chat.QuickChat, profiles=(profile,)):
             widget.onMessageState(uid, status, profile)
 
-    def messageSend(
-        self,
-        to_jid,
-        message,
-        subject=None,
-        mess_type="auto",
-        extra=None,
-        callback=None,
-        errback=None,
-        profile_key=C.PROF_KEY_NONE,
-    ):
+    def messageSend(self, to_jid, message, subject=None, mess_type="auto", extra=None, callback=None, errback=None, profile_key=C.PROF_KEY_NONE):
+        if not subject and not extra and (not message or message == {u'': u''}):
+            log.debug(u"Not sending empty message")
+            return
+
         if subject is None:
             subject = {}
         if extra is None:
@@ -753,17 +747,7 @@
                 failure.fullname, failure.message, "error"
             )
 
-        if not self.trigger.point(
-            "messageSendTrigger",
-            to_jid,
-            message,
-            subject,
-            mess_type,
-            extra,
-            callback,
-            errback,
-            profile_key=profile_key,
-        ):
+        if not self.trigger.point("messageSendTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key):
             return
 
         self.bridge.messageSend(