Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: 0f6f37be by lovetox at 2021-08-29T21:27:52+02:00 Contacts: Improve supports() - - - - - 1 changed file: - gajim/common/modules/contacts.py Changes: ===================================== gajim/common/modules/contacts.py ===================================== @@ -134,10 +134,11 @@ def _on_signal(self, _contact, signal_name, *args, **kwargs): self.notify(signal_name, *args, **kwargs) def supports(self, requested_feature): - if not self.is_available: - return False + return self._supports(self._jid, requested_feature) - disco_info = app.storage.cache.get_last_disco_info(self._jid) + @staticmethod + def _supports(jid, requested_feature): + disco_info = app.storage.cache.get_last_disco_info(jid) if disco_info is None: return False @@ -167,6 +168,12 @@ def __init__(self, logger, jid, account): self._avatar_sha = app.storage.cache.get_contact(jid, 'avatar') + def supports(self, requested_feature): + for resource in self.iter_resources(): + if resource.supports(requested_feature): + return True + return False + def add_resource(self, resource): jid = self._jid.new_with(resource=resource) contact = ResourceContact(self._log, jid, self._account) @@ -185,13 +192,13 @@ def get_resource(self, resource): def get_resources(self): resources = [] for contact in self._resources.values(): - if contact.show != PresenceShowExt.OFFLINE: + if contact.is_available: resources.append(contact) return resources def iter_resources(self): for contact in self._resources.values(): - if contact.show != PresenceShowExt.OFFLINE: + if contact.is_available: yield contact @property @@ -306,6 +313,11 @@ def __init__(self, logger, jid, account): self._presence = UNKNOWN_PRESENCE + def supports(self, requested_feature): + if not self.is_available: + return False + return CommonContact.supports(self, requested_feature) + @property def is_available(self): return self._presence.available @@ -457,6 +469,11 @@ def __init__(self, logger, jid, account): self._presence = UNKNOWN_MUC_PRESENCE + def supports(self, requested_feature): + if not self.is_available: + return False + return CommonContact.supports(self, requested_feature) + @property def is_pm_contact(self): return True View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/0f6f37be8964d5c6c4ed6a9f77958f1ab24e01d2 -- View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/0f6f37be8964d5c6c4ed6a9f77958f1ab24e01d2 You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits