comparison sat_frontends/quick_frontend/quick_app.py @ 2848:b9da74c9d46e

quick_frontend(app): fixed use of bare jid for target when getting a new message: in newMessage handler, full jid was sometime used for target, while is should always be bare jid. Full jid is used in the messageNew method of each widget.
author Goffi <goffi@goffi.org>
date Sun, 10 Mar 2019 18:02:56 +0100
parents 58ea675d0f05
children eb9fa72eb62b
comparison
equal deleted inserted replaced
2847:c055a3a4ecb0 2848:b9da74c9d46e
700 def messageNewHandler(self, uid, timestamp, from_jid_s, to_jid_s, msg, subject, type_, 700 def messageNewHandler(self, uid, timestamp, from_jid_s, to_jid_s, msg, subject, type_,
701 extra, profile): 701 extra, profile):
702 from_jid = jid.JID(from_jid_s) 702 from_jid = jid.JID(from_jid_s)
703 to_jid = jid.JID(to_jid_s) 703 to_jid = jid.JID(to_jid_s)
704 if not self.trigger.point( 704 if not self.trigger.point(
705 "messageNewTrigger", 705 "messageNewTrigger", uid, timestamp, from_jid, to_jid, msg, subject, type_,
706 uid, 706 extra, profile=profile,):
707 timestamp,
708 from_jid,
709 to_jid,
710 msg,
711 subject,
712 type_,
713 extra,
714 profile=profile,
715 ):
716 return 707 return
717 708
718 from_me = from_jid.bare == self.profiles[profile].whoami.bare 709 from_me = from_jid.bare == self.profiles[profile].whoami.bare
719 target = to_jid if from_me else from_jid 710 mess_to_jid = to_jid if from_me else from_jid
711 target = mess_to_jid.bare
720 contact_list = self.contact_lists[profile] 712 contact_list = self.contact_lists[profile]
721 713
722 try: 714 try:
723 is_room = contact_list.isRoom(target.bare) 715 is_room = contact_list.isRoom(target)
724 except exceptions.NotFound: 716 except exceptions.NotFound:
725 is_room = False 717 is_room = False
726 718
727 if target.resource and not is_room: 719 if target.resource and not is_room:
728 # we avoid resource locking, but we must keep resource for private MUC 720 # we avoid resource locking, but we must keep resource for private MUC
729 # messages 721 # messages
730 target = target.bare 722 target = target
731 # we want to be sure to have at least one QuickChat instance 723 # we want to be sure to have at least one QuickChat instance
732 self.widgets.getOrCreateWidget( 724 self.widgets.getOrCreateWidget(
733 quick_chat.QuickChat, 725 quick_chat.QuickChat,
734 target, 726 target,
735 type_ = C.CHAT_GROUP if is_room else C.CHAT_ONE2ONE, 727 type_ = C.CHAT_GROUP if is_room else C.CHAT_ONE2ONE,
748 # we dispatch the message in the widgets 740 # we dispatch the message in the widgets
749 for widget in self.widgets.getWidgets( 741 for widget in self.widgets.getWidgets(
750 quick_chat.QuickChat, target=target, profiles=(profile,) 742 quick_chat.QuickChat, target=target, profiles=(profile,)
751 ): 743 ):
752 widget.messageNew( 744 widget.messageNew(
753 uid, timestamp, from_jid, target, msg, subject, type_, extra, profile 745 uid, timestamp, from_jid, mess_to_jid, msg, subject, type_, extra, profile
754 ) 746 )
755 747
756 def messageEncryptionStartedHandler(self, destinee_jid_s, plugin_data, profile): 748 def messageEncryptionStartedHandler(self, destinee_jid_s, plugin_data, profile):
757 destinee_jid = jid.JID(destinee_jid_s) 749 destinee_jid = jid.JID(destinee_jid_s)
758 plugin_data = data_format.deserialise(plugin_data) 750 plugin_data = data_format.deserialise(plugin_data)