core (xmpp): don't send message without message or subject to bridge (and log a warning in frontends if such a message is received)
This commit is contained in:
parent
6e38be1dab
commit
c2a1ba3793
3 changed files with 49 additions and 43 deletions
|
|
@ -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_):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue