changeset 4052:2ced30f6d5de

plugin XEP-0166, 0176, 0234: minor renaming + type hints
author Goffi <goffi@goffi.org>
date Mon, 29 May 2023 13:32:19 +0200 (19 months ago)
parents c23cad65ae99
children dd39e60ca2aa
files sat/plugins/plugin_xep_0166/models.py sat/plugins/plugin_xep_0176.py sat/plugins/plugin_xep_0234.py
diffstat 3 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0166/models.py	Mon May 29 13:32:08 2023 +0200
+++ b/sat/plugins/plugin_xep_0166/models.py	Mon May 29 13:32:19 2023 +0200
@@ -100,6 +100,10 @@
     @abc.abstractmethod
     def jingle_terminate(
         self,
+        client: SatXMPPEntity,
+        action: str,
+        session: dict,
+        content_name: str,
         reason_elt: domish.Element
     ) -> Union[
         Callable[..., None],
@@ -144,7 +148,7 @@
         action: str,
         session: dict,
         content_name: str,
-        transport_elt: domish.Element
+        reason_elt: domish.Element
     ) -> Union[
         Callable[..., None],
         Callable[..., Awaitable[None]]
@@ -156,7 +160,7 @@
         @param action: Jingle action
         @param session: Jingle Session
         @param content_name: Name of the content
-        @param transport_elt: Transport element
+        @param reason_elt: <reason> element
         """
         pass
 
--- a/sat/plugins/plugin_xep_0176.py	Mon May 29 13:32:08 2023 +0200
+++ b/sat/plugins/plugin_xep_0176.py	Mon May 29 13:32:19 2023 +0200
@@ -290,7 +290,14 @@
 
         return transport_elt
 
-    def jingle_terminate(self, client, action, session, content_name, reason_elt):
+    def jingle_terminate(
+        self,
+        client: SatXMPPEntity,
+        action: str,
+        session: dict,
+        content_name: str,
+        reason_elt: domish.Element,
+    ) -> None:
         log.debug("ICE-UDP session terminated")
 
     def update_candidates(
--- a/sat/plugins/plugin_xep_0234.py	Mon May 29 13:32:08 2023 +0200
+++ b/sat/plugins/plugin_xep_0234.py	Mon May 29 13:32:19 2023 +0200
@@ -697,20 +697,20 @@
             else:
                 raise NotImplementedError
 
-    def jingle_terminate(self, client, action, session, content_name, jingle_elt):
-        if jingle_elt.decline:
+    def jingle_terminate(self, client, action, session, content_name, reason_elt):
+        if reason_elt.decline:
             # progress is the only way to tell to frontends that session has been declined
             progress_id = self.get_progress_id(session, content_name)
             self.host.bridge.progress_error(
                 progress_id, C.PROGRESS_ERROR_DECLINED, client.profile
             )
-        elif not jingle_elt.success:
+        elif not reason_elt.success:
             progress_id = self.get_progress_id(session, content_name)
-            first_child = jingle_elt.firstChildElement()
+            first_child = reason_elt.firstChildElement()
             if first_child is not None:
                 reason = first_child.name
-                if jingle_elt.text is not None:
-                    reason = f"{reason} - {jingle_elt.text}"
+                if reason_elt.text is not None:
+                    reason = f"{reason} - {reason_elt.text}"
             else:
                 reason = C.PROGRESS_ERROR_FAILED
             self.host.bridge.progress_error(