Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0353.py @ 4115:0da563780ffc
plugin XEP-0167, XEP-0353: handle ringing:
- add a `jingle_preflight_info` method in the Jingle Application model to handle this kind
of information
- XEP-0353 is calling `jingle_preflight_info` when a `ringing` message is received
- XEP-0167 use this information to send a `ringing` info to frontends
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 16 Aug 2023 18:33:28 +0200 |
parents | bc60875cb3b8 |
children | 6784d07b99c8 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0353.py Wed Aug 16 18:28:32 2023 +0200 +++ b/libervia/backend/plugins/plugin_xep_0353.py Wed Aug 16 18:33:28 2023 +0200 @@ -29,7 +29,6 @@ from libervia.backend.core.core_types import SatXMPPEntity from libervia.backend.core.i18n import D_, _ from libervia.backend.core.log import getLogger -from libervia.backend.tools import xml_tools log = getLogger(__name__) @@ -215,6 +214,8 @@ return self._handle_accept(client, message_elt, elt) elif elt.name == "reject": return self._handle_reject(client, message_elt, elt) + elif elt.name == "ringing": + return await self._handle_ringing(client, message_elt, elt) else: log.warning(f"invalid element: {elt.toXml}") return True @@ -367,6 +368,20 @@ response_d.errback(RejectException(reason, text)) return False + async def _handle_ringing(self, client, message_elt, ringing_elt): + session_id = ringing_elt["id"] + try: + session = self._j.get_session(client, session_id) + except exceptions.NotFound: + log.warning(f"Session {session_id!r} unknown, ignoring ringing.") + return False + for __, content_data in session["contents"].items(): + await content_data["application"].handler.jingle_preflight_info( + client, session, "ringing", None + ) + + return False + @implementer(iwokkel.IDisco) class Handler(xmlstream.XMPPHandler):