use get_contact() when we give the resource. see #3275
This commit is contained in:
parent
dc2dd87a31
commit
039bf1e10e
2 changed files with 11 additions and 13 deletions
|
@ -218,10 +218,12 @@ class Contacts:
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_contact(self, account, jid, resource):
|
def get_contact(self, account, jid, resource = None):
|
||||||
'''Returns the contact instance for the given resource if it's given
|
'''Returns the contact instance for the given resource if it's given else
|
||||||
or None if there is not'''
|
the first contact is no resource is given or None if there is not'''
|
||||||
if jid in self._contacts[account]:
|
if jid in self._contacts[account]:
|
||||||
|
if not resource:
|
||||||
|
return self._contacts[account][jid][0]
|
||||||
for c in self._contacts[account][jid]:
|
for c in self._contacts[account][jid]:
|
||||||
if c.resource == resource:
|
if c.resource == resource:
|
||||||
return c
|
return c
|
||||||
|
|
16
src/gajim.py
16
src/gajim.py
|
@ -727,9 +727,7 @@ class Interface:
|
||||||
chat_control = self.msg_win_mgr.get_control(jid, account)
|
chat_control = self.msg_win_mgr.get_control(jid, account)
|
||||||
|
|
||||||
# Handle chat states
|
# Handle chat states
|
||||||
contact = gajim.contacts.get_contacts(account, jid, resource)
|
contact = gajim.contacts.get_contact(account, jid, resource)
|
||||||
if contact and isinstance(contact, list):
|
|
||||||
contact = contact[0]
|
|
||||||
if contact:
|
if contact:
|
||||||
if contact.composing_xep != 'XEP-0085': # We cache xep85 support
|
if contact.composing_xep != 'XEP-0085': # We cache xep85 support
|
||||||
contact.composing_xep = composing_xep
|
contact.composing_xep = composing_xep
|
||||||
|
@ -1053,11 +1051,7 @@ class Interface:
|
||||||
elif self.instances[account]['infos'].has_key(array[0] + '/' + array[1]):
|
elif self.instances[account]['infos'].has_key(array[0] + '/' + array[1]):
|
||||||
win = self.instances[account]['infos'][array[0] + '/' + array[1]]
|
win = self.instances[account]['infos'][array[0] + '/' + array[1]]
|
||||||
if win:
|
if win:
|
||||||
c = gajim.contacts.get_contacts(account, array[0], array[1])
|
c = gajim.contacts.get_contact(account, array[0], array[1])
|
||||||
# c is a list when no resource is given. it probably means that contact
|
|
||||||
# is offline, so only on Contact instance
|
|
||||||
if isinstance(c, list) and len(c):
|
|
||||||
c = c[0]
|
|
||||||
if c: # c can be none if it's a gc contact
|
if c: # c can be none if it's a gc contact
|
||||||
c.last_status_time = time.localtime(time.time() - array[2])
|
c.last_status_time = time.localtime(time.time() - array[2])
|
||||||
if array[3]:
|
if array[3]:
|
||||||
|
@ -2190,8 +2184,10 @@ class Interface:
|
||||||
gajim.events.change_jid(account, fjid, jid)
|
gajim.events.change_jid(account, fjid, jid)
|
||||||
resource = None
|
resource = None
|
||||||
fjid = jid
|
fjid = jid
|
||||||
contact = gajim.contacts.get_contacts(account, jid, resource)
|
contact = None
|
||||||
if not contact or isinstance(contact, list):
|
if resource:
|
||||||
|
contact = gajim.contacts.get_contact(account, jid, resource)
|
||||||
|
if not contact:
|
||||||
contact = highest_contact
|
contact = highest_contact
|
||||||
self.roster.new_chat(contact, account, resource = resource)
|
self.roster.new_chat(contact, account, resource = resource)
|
||||||
w = self.msg_win_mgr.get_window(fjid, account)
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
|
Loading…
Add table
Reference in a new issue