From 4bc8c5e6b6e168059f68819ee3c754d5a76500cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 11 Jul 2022 10:56:50 +0200 Subject: [PATCH] get_devices and get_active_devices return Iterable[int] now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- ChangeLog | 4 +++- slixmpp_omemo/__init__.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eafc82..418f380 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ -Version 0.7.1: +Version 0.8.0: xxxx-xx-xx Maxime “pep” Buquet + * Breaking: + - get_devices and get_active_devices now return Iterable[int] instead of Iterable[str] * Changes: - fetch_bundle and fetch_device methods are now public * Added: diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 5e9f89f..3c6b5d3 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -489,7 +489,7 @@ class XEP_0384(BasePlugin): return None - async def _set_device_list(self, device_ids: Optional[Set[int]] = None) -> None: + async def _set_device_list(self, device_ids: Optional[Iterable[int]] = None) -> None: own_jid = self.xmpp.boundjid try: @@ -554,19 +554,19 @@ class XEP_0384(BasePlugin): own_jid.bare, OMEMO_DEVICES_NS, payload=payload, ) - async def get_devices(self, jid: JID) -> Iterable[str]: + async def get_devices(self, jid: JID) -> Iterable[int]: """ Get all devices for a JID. """ devices = await self._omemo().getDevices(jid.bare) - return set(devices.get('active', []) + devices.get('inactive', [])) + return map(int, set(devices.get('active', []) + devices.get('inactive', []))) - async def get_active_devices(self, jid: JID) -> Iterable[str]: + async def get_active_devices(self, jid: JID) -> Iterable[int]: """ Return active device ids. Always contains our own device id. """ devices = await self._omemo().getDevices(jid.bare) - return set(devices.get('active', [])) + return map(int, set(devices.get('active', []))) async def _should_heartbeat(self, jid: JID, device_id: int, prekey: bool) -> bool: """