From 91d32bd0660d83a9f23606840d943f05405385a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 17 Jul 2021 00:01:37 +0200 Subject: xep_0045: Ensure invite and decline to/from are JIDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/plugins/xep_0045/stanza.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/slixmpp/plugins/xep_0045/stanza.py b/slixmpp/plugins/xep_0045/stanza.py index 71eb3fb5..428dbce7 100644 --- a/slixmpp/plugins/xep_0045/stanza.py +++ b/slixmpp/plugins/xep_0045/stanza.py @@ -179,6 +179,21 @@ class MUCInvite(ElementBase): interfaces = {'to', 'from', 'reason'} sub_interfaces = {'reason'} + def get_to(self) -> JID: + return JID(self._get_attr('to')) + + def set_to(self, value: Union[JID, str]): + if not isinstance(value, JID): + value = JID(value) + self._set_attr('to', value) + + def get_from(self) -> JID: + return JID(self._get_attr('from')) + + def set_from(self, value: Union[JID, str]): + if not isinstance(value, JID): + value = JID(value) + self._set_attr('from', value) class MUCDecline(ElementBase): name = 'decline' @@ -187,6 +202,22 @@ class MUCDecline(ElementBase): interfaces = {'to', 'from', 'reason'} sub_interfaces = {'reason'} + def get_to(self) -> JID: + return JID(self._get_attr('to')) + + def set_to(self, value: Union[JID, str]): + if not isinstance(value, JID): + value = JID(value) + self._set_attr('to', value) + + def get_from(self) -> JID: + return JID(self._get_attr('from')) + + def set_from(self, value: Union[JID, str]): + if not isinstance(value, JID): + value = JID(value) + self._set_attr('from', value) + class MUCHistory(ElementBase): name = 'history' -- cgit v1.2.3