diff --git a/sat/core/xmpp.py b/sat/core/xmpp.py index b571f1d6..a1b58865 100644 --- a/sat/core/xmpp.py +++ b/sat/core/xmpp.py @@ -971,17 +971,21 @@ class SatMessageProtocol(xmppim.MessageProtocol): 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_): diff --git a/sat_frontends/primitivus/chat.py b/sat_frontends/primitivus/chat.py index 83581b75..0595373b 100644 --- a/sat_frontends/primitivus/chat.py +++ b/sat_frontends/primitivus/chat.py @@ -492,42 +492,39 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat): 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)) + wid = MessageWidget(message) + self.mess_walker.append(wid) + self._scrollDown() + if self._user_moved(message): + return # no notification for moved messages + + # notifications + + 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 + ) + 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: - wid = MessageWidget(message) - self.mess_walker.append(wid) - self._scrollDown() - if self._user_moved(message): - return # no notification for moved messages - - # notifications - - 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 - ) - 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_MESSAGE, self.target, widget=self, profile=self.profile + ) def addUser(self, nick): occupant = super(Chat, self).addUser(nick) diff --git a/sat_frontends/quick_frontend/quick_chat.py b/sat_frontends/quick_frontend/quick_chat.py index bd40c5fd..da5ac699 100644 --- a/sat_frontends/quick_frontend/quick_chat.py +++ b/sat_frontends/quick_frontend/quick_chat.py @@ -584,6 +584,11 @@ class QuickChat(quick_widgets.QuickWidget): profile, ) return + + if not msg and not subject and type_ != C.MESS_TYPE_INFO: + log.warning(u"Received an empty message for uid {}".format(uid)) + return + if self.type == C.CHAT_GROUP: if to_jid.resource and type_ != C.MESS_TYPE_GROUPCHAT: # we have a private message, we forward it to a private conversation