Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
4342:17fa953c8cd7 | 4343:627f872bc16e |
---|---|
29 from twisted.internet import defer | 29 from twisted.internet import defer |
30 from wokkel import disco, iwokkel, data_form | 30 from wokkel import disco, iwokkel, data_form |
31 from libervia.backend.core.i18n import _, D_ | 31 from libervia.backend.core.i18n import _, D_ |
32 from libervia.backend.core.constants import Const as C | 32 from libervia.backend.core.constants import Const as C |
33 from libervia.backend.core.log import getLogger | 33 from libervia.backend.core.log import getLogger |
34 from libervia.backend.core.xmpp import SatXMPPClient, SatXMPPEntity | 34 from libervia.backend.core.core_types import SatXMPPEntity |
35 from libervia.backend.core import exceptions | 35 from libervia.backend.core import exceptions |
36 from libervia.backend.memory.memory import Sessions | 36 from libervia.backend.memory.memory import Sessions |
37 from libervia.backend.tools import xml_tools, utils | 37 from libervia.backend.tools import xml_tools, utils |
38 from libervia.backend.tools.common import data_format | 38 from libervia.backend.tools.common import data_format |
39 | 39 |
350 node, | 350 node, |
351 action=ACTION.EXECUTE, | 351 action=ACTION.EXECUTE, |
352 session_id=None, | 352 session_id=None, |
353 form_values=None, | 353 form_values=None, |
354 timeout=30, | 354 timeout=30, |
355 ): | 355 ) -> defer.Deferred[domish.Element]: |
356 """Do an Ad-Hoc Command | 356 """Do an Ad-Hoc Command |
357 | 357 |
358 @param entity(jid.JID): entity which will execture the command | 358 @param entity(jid.JID): entity which will execture the command |
359 @param node(unicode): node of the command | 359 @param node(unicode): node of the command |
360 @param action(unicode): one of XEP_0050.ACTION | 360 @param action(unicode): one of XEP_0050.ACTION |
758 | 758 |
759 return answer_data | 759 return answer_data |
760 | 760 |
761 def add_ad_hoc_command( | 761 def add_ad_hoc_command( |
762 self, | 762 self, |
763 client: SatXMPPClient, | 763 client: SatXMPPEntity, |
764 callback: Callable, | 764 callback: Callable, |
765 label: str, | 765 label: str, |
766 node: str | None = None, | 766 node: str | None = None, |
767 features: list[str] | None = None, | 767 features: list[str] | None = None, |
768 timeout: int = 600, | 768 timeout: int = 600, |
812 allowed_jids = allowed_jids.copy() | 812 allowed_jids = allowed_jids.copy() |
813 if allowed_groups is None: | 813 if allowed_groups is None: |
814 allowed_groups = [] | 814 allowed_groups = [] |
815 if allowed_magics is None: | 815 if allowed_magics is None: |
816 allowed_magics = [C.ENTITY_PROFILE_BARE] | 816 allowed_magics = [C.ENTITY_PROFILE_BARE] |
817 elif isinstance(allowed_magics, str): | |
818 raise exceptions.InternalError("Allowed magic must be a list of strings!") | |
817 if forbidden_jids is None: | 819 if forbidden_jids is None: |
818 forbidden_jids = [] | 820 forbidden_jids = [] |
819 if forbidden_groups is None: | 821 if forbidden_groups is None: |
820 forbidden_groups = [] | 822 forbidden_groups = [] |
821 | 823 |