Ensure devicelist and bundles are published after receiving precondition-not-met
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
fc8349a5a3
commit
b380bfa7d6
1 changed files with 17 additions and 4 deletions
|
@ -299,7 +299,7 @@ class XEP_0384(BasePlugin):
|
||||||
form,
|
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)
|
bundle = self._omemo.public_bundle.serialize(self.omemo_backend)
|
||||||
|
|
||||||
jid = self.xmpp.boundjid
|
jid = self.xmpp.boundjid
|
||||||
|
@ -328,7 +328,7 @@ class XEP_0384(BasePlugin):
|
||||||
prekeys.append(prekey)
|
prekeys.append(prekey)
|
||||||
payload['prekeys'] = prekeys
|
payload['prekeys'] = prekeys
|
||||||
|
|
||||||
if publish_options:
|
if publish_options and publish_options:
|
||||||
options = _make_publish_options_form({
|
options = _make_publish_options_form({
|
||||||
'pubsub#persist_items': True,
|
'pubsub#persist_items': True,
|
||||||
'pubsub#access_model': 'open',
|
'pubsub#access_model': 'open',
|
||||||
|
@ -354,7 +354,13 @@ class XEP_0384(BasePlugin):
|
||||||
'Trying to configure manually..')
|
'Trying to configure manually..')
|
||||||
# TODO: We should attempt setting this node to the same
|
# TODO: We should attempt setting this node to the same
|
||||||
# access_model as the devicelist node for completness.
|
# 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]:
|
async def _fetch_bundle(self, jid: str, device_id: int) -> Optional[ExtendedPublicBundle]:
|
||||||
node = '%s:%d' % (OMEMO_BUNDLES_NS, device_id)
|
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 '
|
log.debug('The node we tried to publish was already '
|
||||||
'existing with a different configuration. '
|
'existing with a different configuration. '
|
||||||
'Trying to configure manually..')
|
'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]:
|
def get_device_list(self, jid: JID) -> List[str]:
|
||||||
"""Return active device ids. Always contains our own device id."""
|
"""Return active device ids. Always contains our own device id."""
|
||||||
|
|
Loading…
Reference in a new issue