diff sat/core/xmpp.py @ 2736:df2bc2e704bc

core (xmpp): don't send message without message or subject to bridge (and log a warning in frontends if such a message is received)
author Goffi <goffi@goffi.org>
date Wed, 02 Jan 2019 18:28:30 +0100
parents a58e380c1c37
children 1f5b02623355
line wrap: on
line diff
--- a/sat/core/xmpp.py	Wed Jan 02 18:25:55 2019 +0100
+++ b/sat/core/xmpp.py	Wed Jan 02 18:28:30 2019 +0100
@@ -971,17 +971,21 @@
         if C.MESS_KEY_ENCRYPTION in data:
             data[u"extra"][u"encrypted"] = C.BOOL_TRUE
         if data is not None:
-            self.host.bridge.messageNew(
-                data["uid"],
-                data["timestamp"],
-                data["from"].full(),
-                data["to"].full(),
-                data["message"],
-                data["subject"],
-                data["type"],
-                data["extra"],
-                profile=self.parent.profile,
-            )
+            if data["message"] or data["subject"] or data["type"] == C.MESS_TYPE_INFO:
+                self.host.bridge.messageNew(
+                    data["uid"],
+                    data["timestamp"],
+                    data["from"].full(),
+                    data["to"].full(),
+                    data["message"],
+                    data["subject"],
+                    data["type"],
+                    data["extra"],
+                    profile=self.parent.profile,
+                )
+            else:
+                log.debug(u"Discarding bridge signal for empty message: {data}".format(
+                    data=data))
         return data
 
     def cancelErrorTrap(self, failure_):