get_devices and get_active_devices return Iterable[int] now
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
cda11a82bc
commit
4bc8c5e6b6
2 changed files with 8 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
Version 0.7.1:
|
||||
Version 0.8.0:
|
||||
xxxx-xx-xx Maxime “pep” Buquet <pep@bouah.net>
|
||||
* 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:
|
||||
|
|
|
@ -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:
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue