comparison 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
comparison
equal deleted inserted replaced
2735:ba74914277cf 2736:df2bc2e704bc
490 self._scrollDown() 490 self._scrollDown()
491 else: 491 else:
492 if self.focus_marker_set: 492 if self.focus_marker_set:
493 self.focus_marker_set = False 493 self.focus_marker_set = False
494 494
495 if not message.message: 495 wid = MessageWidget(message)
496 log.error(u"Received an empty message for uid {}".format(message.uid)) 496 self.mess_walker.append(wid)
497 self._scrollDown()
498 if self._user_moved(message):
499 return # no notification for moved messages
500
501 # notifications
502
503 if self._locked:
504 # we don't want notifications when locked
505 # because that's history messages
506 return
507
508 if wid.mess_data.mention:
509 from_jid = wid.mess_data.from_jid
510 msg = _(
511 u"You have been mentioned by {nick} in {room}".format(
512 nick=wid.mess_data.nick, room=self.target
513 )
514 )
515 self.host.notify(
516 C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
517 )
518 elif self.type == C.CHAT_ONE2ONE:
519 from_jid = wid.mess_data.from_jid
520 msg = _(u"{entity} is talking to you".format(entity=from_jid))
521 self.host.notify(
522 C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile
523 )
497 else: 524 else:
498 wid = MessageWidget(message) 525 self.host.notify(
499 self.mess_walker.append(wid) 526 C.NOTIFY_MESSAGE, self.target, widget=self, profile=self.profile
500 self._scrollDown() 527 )
501 if self._user_moved(message):
502 return # no notification for moved messages
503
504 # notifications
505
506 if self._locked:
507 # we don't want notifications when locked
508 # because that's history messages
509 return
510
511 if wid.mess_data.mention:
512 from_jid = wid.mess_data.from_jid
513 msg = _(
514 u"You have been mentioned by {nick} in {room}".format(
515 nick=wid.mess_data.nick, room=self.target
516 )
517 )
518 self.host.notify(
519 C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
520 )
521 elif self.type == C.CHAT_ONE2ONE:
522 from_jid = wid.mess_data.from_jid
523 msg = _(u"{entity} is talking to you".format(entity=from_jid))
524 self.host.notify(
525 C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile
526 )
527 else:
528 self.host.notify(
529 C.NOTIFY_MESSAGE, self.target, widget=self, profile=self.profile
530 )
531 528
532 def addUser(self, nick): 529 def addUser(self, nick):
533 occupant = super(Chat, self).addUser(nick) 530 occupant = super(Chat, self).addUser(nick)
534 self.occupants_widget.addUser(occupant) 531 self.occupants_widget.addUser(occupant)
535 532