Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0060.py @ 4356:c9626f46b63e
plugin XEP-0059: Use Pydantic models for RSM.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 Apr 2025 18:19:28 +0200 |
parents | e9971a4b0627 |
children |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0060.py Fri Apr 11 18:19:28 2025 +0200 +++ b/libervia/backend/plugins/plugin_xep_0060.py Fri Apr 11 18:19:28 2025 +0200 @@ -40,6 +40,7 @@ from libervia.backend.core.i18n import _ from libervia.backend.core.log import getLogger from libervia.backend.core.xmpp import SatXMPPClient +from libervia.backend.plugins.plugin_xep_0059 import RSMRequest from libervia.backend.tools import utils from libervia.backend.tools import sat_defer from libervia.backend.tools import xml_tools @@ -812,7 +813,7 @@ max_items: int | None = None, item_ids: list[str] | None = None, sub_id: str | None = None, - rsm_request: rsm.RSMRequest | None = None, + rsm_request: rsm.RSMRequest | RSMRequest | None = None, extra: dict | None = None, ) -> tuple[list[domish.Element], dict]: """Retrieve pubsub items from a node. @@ -833,6 +834,15 @@ value of RSMResponse - service, node: service and node used """ + if rsm_request is not None: + # For the moment we convert RSMRequest to wokkel rsm.RSMRequest for backward + # compatibility with other plugins. In the future we should work as much as + # possible with XEP-0059's plugin RSMRequest, and convert to Wokkel + # rsm.RSMRequest only when we need to work with wokkel directly. + if isinstance(rsm_request, rsm.RSMRequest): + log.warning("Use for rsm.RSMRequest is deprecated") + else: + rsm_request = rsm_request.to_wokkel_request() if item_ids and max_items is not None: max_items = None if rsm_request and item_ids: