Remove get_device_list in favor of get_devices and get_active_devices

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-03-24 19:53:53 +01:00
parent 48b0610f89
commit 13052817bf
2 changed files with 16 additions and 4 deletions

View file

@ -1,5 +1,8 @@
Version XXX:
2022-XX-XX Maxime “pep” Buquet <pep@bouah.net>
* 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

View file

@ -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:
"""