diff options
author | lovetox <philipp@hoerist.com> | 2022-08-13 22:15:33 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2022-08-13 22:15:33 +0300 |
commit | 83f9ed16a12fb7b42bd4f16fd5446b64280c94b5 (patch) | |
tree | 3d99f8a125a80fb4f41a605573aa477050577fea | |
parent | 8c1722e1ad6f5b53ae40946f71e6fb4316f7deea (diff) |
refactor: Contacts: Make contacts a hashable object
-rw-r--r-- | gajim/common/modules/contacts.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gajim/common/modules/contacts.py b/gajim/common/modules/contacts.py index 1c41d0a48..dae140bf1 100644 --- a/gajim/common/modules/contacts.py +++ b/gajim/common/modules/contacts.py @@ -265,6 +265,16 @@ class CommonContact(Observable): self._jid = jid self._account = account + def __hash__(self) -> int: + return hash(f'{self._account}-{self._jid}') + + def __eq__(self, obj: object) -> bool: + if not isinstance(obj, CommonContact): + return NotImplemented + + return (self._account == obj.account and + obj._jid == self._jid) + def _module(self, name: str) -> BaseModule: return app.get_client(self._account).get_module(name) |