diff --git a/src/gajim.py b/src/gajim.py index 9f0b36a23..12534e568 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -402,12 +402,13 @@ class Interface: elif contact1.show in statuss: old_show = statuss.index(contact1.show) if (resources != [''] and (len(lcontact) != 1 or - lcontact[0].show != 'offline')) and jid.find('@') > 0: + lcontact[0].show != 'offline')) and jid.find('@') > 0: old_show = 0 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: @@ -578,7 +579,7 @@ class Interface: # Is it a first or next message received ? first = False if msg_type == 'normal': - if not gajim.events.get_events(account,jid, ['normal']): + if not gajim.events.get_events(account, jid, ['normal']): first = True elif not chat_control and not gajim.events.get_events(account, jid_of_control, [msg_type]): # msg_type can be chat or pm diff --git a/src/roster_window.py b/src/roster_window.py index 706753ee0..1b917fa4b 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2795,10 +2795,23 @@ _('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: - # Default to highest prio - fjid = jid - resource_for_chat = None - contact = highest_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 + contact = highest_contact if not contact: # contact is not in roster contact = self.add_to_not_in_the_roster(account, jid)