Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0249.py @ 4245:a7d4007a8fa5
plugin XEP-0272: implement XEP-0272: Multiparty Jingle (Muji)
rel 429
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 15 May 2024 17:34:46 +0200 |
parents | 4b842c1fb686 |
children | 0d7bb4df2343 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0249.py Sat May 11 13:52:43 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0249.py Wed May 15 17:34:46 2024 +0200 @@ -25,6 +25,7 @@ from libervia.backend.core import exceptions from libervia.backend.core.constants import Const as C +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 @@ -57,7 +58,7 @@ } -class XEP_0249(object): +class XEP_0249: params = """ <params> @@ -112,12 +113,20 @@ client = self.host.get_client(profile_key) self.invite(client, jid.JID(guest_jid_s), jid.JID(room_jid_s, options)) - def invite(self, client, guest, room, options={}): + def invite( + self, + client: SatXMPPEntity, + guest: jid.JID, + room: jid.JID, + # the dict is only used internally, so we can safely use a default dict instead of + # None here. + **options + ) -> None: """Invite a user to a room - @param guest(jid.JID): jid of the user to invite - @param room(jid.JID): jid of the room where the user is invited - @param options(dict): attribute with extra info (reason, password) as in #XEP-0249 + @param guest: jid of the user to invite + @param room: jid of the room where the user is invited + @param options: attribute with extra info (reason, password) as in #XEP-0249 """ message = domish.Element((None, "message")) message["to"] = guest.full() @@ -128,7 +137,6 @@ log.warning("Ignoring invalid invite option: {}".format(key)) continue x_elt[key] = value - # there is not body in this message, so we can use directly send() client.send(message) def _accept(self, room_jid, profile_key=C.PROF_KEY_NONE): @@ -188,13 +196,20 @@ title = D_("MUC invitation") xml_tools.quick_note(self.host, client, msg, title, C.XMLUI_DATA_LVL_INFO) else: # leave the default value here + action_extra = { + "type": C.META_TYPE_CONFIRM, + "subtype": C.META_TYPE_MUC_INVIRATION, + "from_jid": from_jid_s, + "room_jid": room_jid_s + } confirm_msg = D_( "You have been invited by %(user)s to join the room %(room)s. " "Do you accept?" ) % {"user": from_jid_s, "room": room_jid_s} confirm_title = D_("MUC invitation") d = xml_tools.defer_confirm( - self.host, confirm_msg, confirm_title, profile=client.profile + self.host, confirm_msg, confirm_title, profile=client.profile, + action_extra=action_extra ) def accept_cb(accepted):