Add get_contact_strict()
This adds a method that returns only a contact if there is an exact match, instead of a contact where only the barejid matches. We need this when we update the Caps of a contact.
This commit is contained in:
parent
c6e39309cf
commit
a4bfd2fcbb
|
@ -509,6 +509,15 @@ class Contacts():
|
||||||
return c
|
return c
|
||||||
return self._contacts[jid][0]
|
return self._contacts[jid][0]
|
||||||
|
|
||||||
|
def get_contact_strict(self, jid, resource):
|
||||||
|
"""
|
||||||
|
Return the contact instance for the given resource or None
|
||||||
|
"""
|
||||||
|
if jid in self._contacts:
|
||||||
|
for c in self._contacts[jid]:
|
||||||
|
if c.resource == resource:
|
||||||
|
return c
|
||||||
|
|
||||||
def get_avatar(self, jid, size=None, scale=None):
|
def get_avatar(self, jid, size=None, scale=None):
|
||||||
if jid not in self._contacts:
|
if jid not in self._contacts:
|
||||||
return None
|
return None
|
||||||
|
@ -554,7 +563,7 @@ class Contacts():
|
||||||
Get Contact object for specific resource of given jid
|
Get Contact object for specific resource of given jid
|
||||||
"""
|
"""
|
||||||
barejid, resource = common.app.get_room_and_nick_from_fjid(fjid)
|
barejid, resource = common.app.get_room_and_nick_from_fjid(fjid)
|
||||||
return self.get_contact(barejid, resource)
|
return self.get_contact_strict(barejid, resource)
|
||||||
|
|
||||||
def get_first_contact_from_jid(self, jid):
|
def get_first_contact_from_jid(self, jid):
|
||||||
if jid in self._contacts:
|
if jid in self._contacts:
|
||||||
|
|
Loading…
Reference in New Issue