Only use publish-options if advertized by the server
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
c7e54488b7
commit
a07c3d9745
1 changed files with 14 additions and 7 deletions
|
@ -52,6 +52,7 @@ except (ImportError,):
|
|||
HAS_OMEMO = False
|
||||
|
||||
TRUE_VALUES = {True, 'true', '1'}
|
||||
PUBLISH_OPTIONS_NODE = 'http://jabber.org/protocol/pubsub#publish-options'
|
||||
|
||||
|
||||
def b64enc(data: bytes) -> str:
|
||||
|
@ -229,16 +230,22 @@ class XEP_0384(BasePlugin):
|
|||
def my_device_id(self) -> int:
|
||||
return self._device_id
|
||||
|
||||
def _generate_bundle_iq(self) -> Iq:
|
||||
async def _generate_bundle_iq(self) -> Iq:
|
||||
bundle = self._omemo.public_bundle.serialize(self.omemo_backend)
|
||||
|
||||
options = _make_publish_options_form({
|
||||
'pubsub#persist_items': True,
|
||||
'pubsub#access_model': 'open',
|
||||
})
|
||||
jid = self.xmpp.boundjid
|
||||
items = await self.xmpp['xep_0030'].get_items(jid)
|
||||
publish_options = PUBLISH_OPTIONS_NODE in items['features']
|
||||
|
||||
iq = self.xmpp.Iq(stype='set')
|
||||
iq['pubsub']['publish_options'] = options
|
||||
|
||||
if publish_options:
|
||||
options = _make_publish_options_form({
|
||||
'pubsub#persist_items': True,
|
||||
'pubsub#access_model': 'open',
|
||||
})
|
||||
iq['pubsub']['publish_options'] = options
|
||||
|
||||
publish = iq['pubsub']['publish']
|
||||
publish['node'] = '%s:%d' % (OMEMO_BUNDLES_NS, self._device_id)
|
||||
payload = publish['item']['bundle']
|
||||
|
@ -263,7 +270,7 @@ class XEP_0384(BasePlugin):
|
|||
|
||||
async def _publish_bundle(self) -> None:
|
||||
if self._omemo.republish_bundle:
|
||||
iq = self._generate_bundle_iq()
|
||||
iq = await self._generate_bundle_iq()
|
||||
await iq.send()
|
||||
|
||||
async def _fetch_bundle(self, jid: str, device_id: int) -> Optional[ExtendedPublicBundle]:
|
||||
|
|
Loading…
Reference in a new issue