xep_0045: Ensure invite and decline to/from are JIDs

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2021-07-17 00:01:37 +02:00
parent 22fa8bc4d9
commit 91d32bd066
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -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'