diff --git a/ChangeLog b/ChangeLog index e2b786d..39ff531 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ Version XXX: 2022-XX-XX Maxime “pep” Buquet + * Breaking: + - Removed get_device_list method in favor of newly added get_devices and + get_active_devices methods. * Improvements: - Added py.typed to the repository for static type checking tools - New delete_session method diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 113b001..ac8af37 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -478,7 +478,7 @@ class XEP_0384(BasePlugin): return # XXX: Handle this! if device_ids is None: - device_ids = await self.get_device_list(own_jid) + device_ids = await self.get_active_devices(own_jid) devices = [] for i in device_ids: @@ -527,10 +527,19 @@ class XEP_0384(BasePlugin): own_jid.bare, OMEMO_DEVICES_NS, payload=payload, ) - async def get_device_list(self, jid: JID) -> List[str]: - """Return active device ids. Always contains our own device id.""" + async def get_devices(self, jid: JID) -> Iterable[str]: + """ + Get all devices for a JID. + """ devices = await self._omemo().getDevices(jid.bare) - return devices.get('active', []) + return set(devices.get('active', []) + devices.get('inactive', [])) + + async def get_active_devices(self, jid: JID) -> Iterable[str]: + """ + Return active device ids. Always contains our own device id. + """ + devices = await self._omemo().getDevices(jid.bare) + return set(devices.get('active', [])) async def _should_heartbeat(self, jid: JID, device_id: int, prekey: bool) -> bool: """