diff libervia/backend/plugins/plugin_xep_0050.py @ 4343:627f872bc16e

plugin XEP-0050: fix `allowed_magics` arg and calls to `add_ad_hoc_command`.
author Goffi <goffi@goffi.org>
date Mon, 13 Jan 2025 01:23:22 +0100
parents 50c919dfe61b
children
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0050.py	Mon Jan 13 01:23:10 2025 +0100
+++ b/libervia/backend/plugins/plugin_xep_0050.py	Mon Jan 13 01:23:22 2025 +0100
@@ -31,7 +31,7 @@
 from libervia.backend.core.i18n import _, D_
 from libervia.backend.core.constants import Const as C
 from libervia.backend.core.log import getLogger
-from libervia.backend.core.xmpp import SatXMPPClient, SatXMPPEntity
+from libervia.backend.core.core_types import SatXMPPEntity
 from libervia.backend.core import exceptions
 from libervia.backend.memory.memory import Sessions
 from libervia.backend.tools import xml_tools, utils
@@ -352,7 +352,7 @@
         session_id=None,
         form_values=None,
         timeout=30,
-    ):
+    ) -> defer.Deferred[domish.Element]:
         """Do an Ad-Hoc Command
 
         @param entity(jid.JID): entity which will execture the command
@@ -760,7 +760,7 @@
 
     def add_ad_hoc_command(
         self,
-        client: SatXMPPClient,
+        client: SatXMPPEntity,
         callback: Callable,
         label: str,
         node: str | None = None,
@@ -814,6 +814,8 @@
             allowed_groups = []
         if allowed_magics is None:
             allowed_magics = [C.ENTITY_PROFILE_BARE]
+        elif isinstance(allowed_magics, str):
+            raise exceptions.InternalError("Allowed magic must be a list of strings!")
         if forbidden_jids is None:
             forbidden_jids = []
         if forbidden_groups is None: