Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
4282:8da377040ba6 | 4283:23842a63ea00 |
---|---|
600 - self.EXTRA_PUBLISH_OPTIONS(dict): publish options, cf. XEP-0060 § 7.1.5 | 600 - self.EXTRA_PUBLISH_OPTIONS(dict): publish options, cf. XEP-0060 § 7.1.5 |
601 the dict maps option name to value(s) | 601 the dict maps option name to value(s) |
602 - self.EXTRA_ON_PRECOND_NOT_MET(str): policy to have when publishing is | 602 - self.EXTRA_ON_PRECOND_NOT_MET(str): policy to have when publishing is |
603 failing du to failing precondition. Value can be: | 603 failing du to failing precondition. Value can be: |
604 * raise (default): raise the exception | 604 * raise (default): raise the exception |
605 * force: try to re-configure the node with the given option. Be sure to | |
606 use this option carefully, and not not give public access to a node | |
607 which has not on purpose. | |
605 * publish_without_options: re-publish without the publish-options. | 608 * publish_without_options: re-publish without the publish-options. |
606 A warning will be logged showing that the publish-options could not | 609 A warning will be logged showing that the publish-options could not |
607 be used | 610 be used |
608 @return: ids of the created items | 611 @return: ids of the created items |
609 """ | 612 """ |
636 ): | 639 ): |
637 # this usually happens when publish-options can't be set | 640 # this usually happens when publish-options can't be set |
638 policy = extra.get(self.EXTRA_ON_PRECOND_NOT_MET, "raise") | 641 policy = extra.get(self.EXTRA_ON_PRECOND_NOT_MET, "raise") |
639 if policy == "raise": | 642 if policy == "raise": |
640 raise e | 643 raise e |
644 elif policy == "force": | |
645 log.debug( | |
646 f"[{client.profile}] Force configuration for {nodeIdentifier!r} " | |
647 f"at {service}: {publish_options}" | |
648 ) | |
649 await self.setConfiguration( | |
650 client, service, nodeIdentifier, publish_options | |
651 ) | |
652 log.debug("Configuration updated.") | |
653 return await self.send_items( | |
654 client, service, nodeIdentifier, items, sender, extra | |
655 ) | |
656 | |
641 elif policy == "publish_without_options": | 657 elif policy == "publish_without_options": |
642 log.warning( | 658 log.warning( |
643 _( | 659 _( |
644 "Can't use publish-options ({options}) on node {node}, " | 660 "Can't use publish-options ({options}) on node {node}, " |
645 "re-publishing without them: {reason}" | 661 "re-publishing without them: {reason}" |