plugin XEP-0060: getItem(s), publish and (un)subscribe are now coroutines
This commit is contained in:
parent
a3e6425eb2
commit
bab851006f
1 changed files with 165 additions and 161 deletions
|
|
@ -792,8 +792,7 @@ class OMEMO:
|
|||
devices.add(device_id)
|
||||
return devices
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def getDevices(self, client, entity_jid=None):
|
||||
async def getDevices(self, client, entity_jid=None):
|
||||
"""Retrieve list of registered OMEMO devices
|
||||
|
||||
@param entity_jid(jid.JID, None): get devices from this entity
|
||||
|
|
@ -803,13 +802,13 @@ class OMEMO:
|
|||
if entity_jid is not None:
|
||||
assert not entity_jid.resource
|
||||
try:
|
||||
items, metadata = yield self._p.getItems(client, entity_jid, NS_OMEMO_DEVICES)
|
||||
items, metadata = await self._p.getItems(client, entity_jid, NS_OMEMO_DEVICES)
|
||||
except exceptions.NotFound:
|
||||
log.info(_("there is no node to handle OMEMO devices"))
|
||||
defer.returnValue(set())
|
||||
return set()
|
||||
|
||||
devices = self.parseDevices(items)
|
||||
defer.returnValue(devices)
|
||||
return devices
|
||||
|
||||
async def setDevices(self, client, devices):
|
||||
log.debug(f"setting devices with {', '.join(str(d) for d in devices)}")
|
||||
|
|
@ -831,8 +830,7 @@ class OMEMO:
|
|||
|
||||
# bundles
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def getBundles(self, client, entity_jid, devices_ids):
|
||||
async def getBundles(self, client, entity_jid, devices_ids):
|
||||
"""Retrieve public bundles of an entity devices
|
||||
|
||||
@param entity_jid(jid.JID): bare jid of entity
|
||||
|
|
@ -849,7 +847,7 @@ class OMEMO:
|
|||
for device_id in devices_ids:
|
||||
node = NS_OMEMO_BUNDLE.format(device_id=device_id)
|
||||
try:
|
||||
items, metadata = yield self._p.getItems(client, entity_jid, node)
|
||||
items, metadata = await self._p.getItems(client, entity_jid, node)
|
||||
except exceptions.NotFound:
|
||||
log.warning(_("Bundle missing for device {device_id}")
|
||||
.format(device_id=device_id))
|
||||
|
|
@ -910,7 +908,7 @@ class OMEMO:
|
|||
bundles[device_id] = ExtendedPublicBundle.parse(omemo_backend, ik, spk,
|
||||
spkSignature, otpks)
|
||||
|
||||
defer.returnValue((bundles, missing))
|
||||
return (bundles, missing)
|
||||
|
||||
async def setBundle(self, client, bundle, device_id):
|
||||
"""Set public bundle for this device.
|
||||
|
|
|
|||
Loading…
Reference in a new issue