Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0060.py @ 4283:23842a63ea00
plugin XEP-0060: add a `force` options for publish options in `send_items`:
The new `force` option can be used to force the update of configuration is
`publish-option` fails.
Use this new `force` option in XEP-0384.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jul 2024 16:45:17 +0200 |
parents | 0d7bb4df2343 |
children | 3a550e9a2b55 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0060.py Sat Jul 13 17:45:47 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0060.py Sun Jul 14 16:45:17 2024 +0200 @@ -602,6 +602,9 @@ - self.EXTRA_ON_PRECOND_NOT_MET(str): policy to have when publishing is failing du to failing precondition. Value can be: * raise (default): raise the exception + * force: try to re-configure the node with the given option. Be sure to + use this option carefully, and not not give public access to a node + which has not on purpose. * publish_without_options: re-publish without the publish-options. A warning will be logged showing that the publish-options could not be used @@ -638,6 +641,19 @@ policy = extra.get(self.EXTRA_ON_PRECOND_NOT_MET, "raise") if policy == "raise": raise e + elif policy == "force": + log.debug( + f"[{client.profile}] Force configuration for {nodeIdentifier!r} " + f"at {service}: {publish_options}" + ) + await self.setConfiguration( + client, service, nodeIdentifier, publish_options + ) + log.debug("Configuration updated.") + return await self.send_items( + client, service, nodeIdentifier, items, sender, extra + ) + elif policy == "publish_without_options": log.warning( _(