diff sat_frontends/primitivus/chat.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 56f94936df1e
children 378188abe941
line wrap: on
line diff
--- a/sat_frontends/primitivus/chat.py	Wed Jan 02 18:25:55 2019 +0100
+++ b/sat_frontends/primitivus/chat.py	Wed Jan 02 18:28:30 2019 +0100
@@ -492,42 +492,39 @@
             if self.focus_marker_set:
                 self.focus_marker_set = False
 
-        if not message.message:
-            log.error(u"Received an empty message for uid {}".format(message.uid))
-        else:
-            wid = MessageWidget(message)
-            self.mess_walker.append(wid)
-            self._scrollDown()
-            if self._user_moved(message):
-                return  # no notification for moved messages
+        wid = MessageWidget(message)
+        self.mess_walker.append(wid)
+        self._scrollDown()
+        if self._user_moved(message):
+            return  # no notification for moved messages
 
-            # notifications
+        # notifications
 
-            if self._locked:
-                # we don't want notifications when locked
-                # because that's history messages
-                return
+        if self._locked:
+            # we don't want notifications when locked
+            # because that's history messages
+            return
 
-            if wid.mess_data.mention:
-                from_jid = wid.mess_data.from_jid
-                msg = _(
-                    u"You have been mentioned by {nick} in {room}".format(
-                        nick=wid.mess_data.nick, room=self.target
-                    )
-                )
-                self.host.notify(
-                    C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
+        if wid.mess_data.mention:
+            from_jid = wid.mess_data.from_jid
+            msg = _(
+                u"You have been mentioned by {nick} in {room}".format(
+                    nick=wid.mess_data.nick, room=self.target
                 )
-            elif self.type == C.CHAT_ONE2ONE:
-                from_jid = wid.mess_data.from_jid
-                msg = _(u"{entity} is talking to you".format(entity=from_jid))
-                self.host.notify(
-                    C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile
-                )
-            else:
-                self.host.notify(
-                    C.NOTIFY_MESSAGE, self.target, widget=self, profile=self.profile
-                )
+            )
+            self.host.notify(
+                C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
+            )
+        elif self.type == C.CHAT_ONE2ONE:
+            from_jid = wid.mess_data.from_jid
+            msg = _(u"{entity} is talking to you".format(entity=from_jid))
+            self.host.notify(
+                C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile
+            )
+        else:
+            self.host.notify(
+                C.NOTIFY_MESSAGE, self.target, widget=self, profile=self.profile
+            )
 
     def addUser(self, nick):
         occupant = super(Chat, self).addUser(nick)