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.
This commit is contained in:
Goffi 2019-03-10 18:02:56 +01:00
commit 93ac4db950

View file

@ -702,32 +702,24 @@ class QuickApp(object):
from_jid = jid.JID(from_jid_s) from_jid = jid.JID(from_jid_s)
to_jid = jid.JID(to_jid_s) to_jid = jid.JID(to_jid_s)
if not self.trigger.point( if not self.trigger.point(
"messageNewTrigger", "messageNewTrigger", uid, timestamp, from_jid, to_jid, msg, subject, type_,
uid, extra, profile=profile,):
timestamp,
from_jid,
to_jid,
msg,
subject,
type_,
extra,
profile=profile,
):
return return
from_me = from_jid.bare == self.profiles[profile].whoami.bare from_me = from_jid.bare == self.profiles[profile].whoami.bare
target = to_jid if from_me else from_jid mess_to_jid = to_jid if from_me else from_jid
target = mess_to_jid.bare
contact_list = self.contact_lists[profile] contact_list = self.contact_lists[profile]
try: try:
is_room = contact_list.isRoom(target.bare) is_room = contact_list.isRoom(target)
except exceptions.NotFound: except exceptions.NotFound:
is_room = False is_room = False
if target.resource and not is_room: if target.resource and not is_room:
# we avoid resource locking, but we must keep resource for private MUC # we avoid resource locking, but we must keep resource for private MUC
# messages # messages
target = target.bare target = target
# we want to be sure to have at least one QuickChat instance # we want to be sure to have at least one QuickChat instance
self.widgets.getOrCreateWidget( self.widgets.getOrCreateWidget(
quick_chat.QuickChat, quick_chat.QuickChat,
@ -750,7 +742,7 @@ class QuickApp(object):
quick_chat.QuickChat, target=target, profiles=(profile,) quick_chat.QuickChat, target=target, profiles=(profile,)
): ):
widget.messageNew( widget.messageNew(
uid, timestamp, from_jid, target, msg, subject, type_, extra, profile uid, timestamp, from_jid, mess_to_jid, msg, subject, type_, extra, profile
) )
def messageEncryptionStartedHandler(self, destinee_jid_s, plugin_data, profile): def messageEncryptionStartedHandler(self, destinee_jid_s, plugin_data, profile):