Commit b380bfa7 authored by Maxime Buquet's avatar Maxime Buquet

Ensure devicelist and bundles are published after receiving precondition-not-met

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent fc8349a5
......@@ -299,7 +299,7 @@ class XEP_0384(BasePlugin):
form,
)
async def _generate_bundle_iq(self) -> Iq:
async def _generate_bundle_iq(self, publish_options: bool = True) -> Iq:
bundle = self._omemo.public_bundle.serialize(self.omemo_backend)
jid = self.xmpp.boundjid
......@@ -328,7 +328,7 @@ class XEP_0384(BasePlugin):
prekeys.append(prekey)
payload['prekeys'] = prekeys
if publish_options:
if publish_options and publish_options:
options = _make_publish_options_form({
'pubsub#persist_items': True,
'pubsub#access_model': 'open',
......@@ -354,7 +354,13 @@ class XEP_0384(BasePlugin):
'Trying to configure manually..')
# TODO: We should attempt setting this node to the same
# access_model as the devicelist node for completness.
await self._set_node_config(OMEMO_BUNDLES_NS)
try:
await self._set_node_config(OMEMO_BUNDLES_NS)
except IqError:
log.debug('Failed to set node to persistent after precondition-not-met')
raise
iq = await self._generate_bundle_iq(publish_options=False)
await iq.send()
async def _fetch_bundle(self, jid: str, device_id: int) -> Optional[ExtendedPublicBundle]:
node = '%s:%d' % (OMEMO_BUNDLES_NS, device_id)
......@@ -456,7 +462,14 @@ class XEP_0384(BasePlugin):
log.debug('The node we tried to publish was already '
'existing with a different configuration. '
'Trying to configure manually..')
await self._set_node_config(OMEMO_DEVICES_NS)
try:
await self._set_node_config(OMEMO_DEVICES_NS)
except IqError:
log.debug('Failed to set node to persistent after precondition-not-met')
raise
await self.xmpp['xep_0060'].publish(
own_jid.bare, OMEMO_DEVICES_NS, payload=payload,
)
def get_device_list(self, jid: JID) -> List[str]:
"""Return active device ids. Always contains our own device id."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment