diff sat_frontends/quick_frontend/quick_app.py @ 2829:649cb3fd7711

quick frontend(app): avoid sending empty messages
author Goffi <goffi@goffi.org>
date Fri, 01 Mar 2019 17:42:28 +0100
parents 0b7ce5daee9b
children 42380a4f6433
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(