handle correctly messages from invisible resources

This commit is contained in:
Yann Leboulanger 2006-11-07 23:13:11 +00:00
parent b2d4177962
commit ae8c6e309e
2 changed files with 22 additions and 8 deletions

View File

@ -407,7 +407,8 @@ class Interface:
contact1 = gajim.contacts.copy_contact(contact1)
lcontact.append(contact1)
contact1.resource = resource
if contact1.jid.find('@') > 0 and len(lcontact) == 1: # It's not an agent
if contact1.jid.find('@') > 0 and len(lcontact) == 1:
# It's not an agent
if old_show == 0 and new_show > 1:
if not contact1.jid in gajim.newly_added[account]:
gajim.newly_added[account].append(contact1.jid)
@ -538,7 +539,7 @@ class Interface:
chat_control = self.msg_win_mgr.get_control(jid, account)
# Handle chat states
contact = gajim.contacts.get_contact(account, jid)
contact = gajim.contacts.get_contact(account, jid, resource)
if contact and isinstance(contact, list):
contact = contact[0]
if contact:

View File

@ -2795,6 +2795,19 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
highest_contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
if not contact:
# If there is another resource, it may be a message from an invisible
# resource
lcontact = gajim.contacts.get_contacts_from_jid(account, jid)
if (len(lcontact) != 1 or lcontact[0].show != 'offline') and \
jid.find('@') > 0:
contact = gajim.contacts.copy_contact(highest_contact)
contact.resource = resource
contact.priority = 0
contact.show = 'offline'
contact.status = ''
gajim.contacts.add_contact(account, contact)
else:
# Default to highest prio
fjid = jid
resource_for_chat = None