diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 711d3d4..f313ab2 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -241,13 +241,6 @@ class XEP_0384(BasePlugin): iq = self.xmpp.Iq(stype='set') - 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'] @@ -268,6 +261,13 @@ class XEP_0384(BasePlugin): prekeys.append(prekey) payload['prekeys'] = prekeys + if publish_options: + options = _make_publish_options_form({ + 'pubsub#persist_items': True, + 'pubsub#access_model': 'open', + }) + iq['pubsub']['publish_options'] = options + return iq async def _publish_bundle(self) -> None: @@ -348,14 +348,19 @@ class XEP_0384(BasePlugin): payload = Devices() payload['devices'] = devices - options = _make_publish_options_form({ - 'pubsub#persist_items': True, - # Everybody will be able to encrypt for us, without having to add - # us into their roster. This obviously leaks the number of devices - # and the associated metadata of us pushing new device lists every - # so often. - 'pubsub#access_model': 'open', - }) + jid = self.xmpp.boundjid + disco = await self.xmpp['xep_0030'].get_info(jid.bare) + publish_options = PUBLISH_OPTIONS_NODE in disco['disco_info'].get_features() + + if publish_options: + options = _make_publish_options_form({ + 'pubsub#persist_items': True, + # Everybody will be able to encrypt for us, without having to add + # us into their roster. This obviously leaks the number of devices + # and the associated metadata of us pushing new device lists every + # so often. + 'pubsub#access_model': 'open', + }) await self.xmpp['xep_0060'].publish( own_jid.bare, OMEMO_DEVICES_NS, payload=payload, options=options,