xep_0045: Require JID when setting outcast affiliation

Found out when reading poezio/poezio#3536.

“An admin or owner can ban one or more users from a room. The ban MUST
be performed based on the occupant's bare JID.”

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-03-16 16:12:20 +01:00
parent ad610c7ded
commit 60df4ef7aa
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -493,6 +493,8 @@ class XEP_0045(BasePlugin):
"""
if affiliation not in AFFILIATIONS:
raise ValueError('%s is not a valid affiliation' % affiliation)
if affiliation == 'outcast' and not jid:
raise ValueError('Outcast affiliation requires a using a jid')
if not any((jid, nick)):
raise ValueError('One of jid or nick must be set')
iq = self.xmpp.make_iq_set(ito=room, ifrom=ifrom)