Commit 3d567111 authored by Philipp Hörist's avatar Philipp Hörist

MUC: Improve voice request

- Validate JID on incoming voice requests
- Add more data to VoiceRequest
- Add approve_voice_request()
parent 10fe8109
......@@ -33,6 +33,7 @@ from nbxmpp.protocol import Message
from nbxmpp.protocol import DataForm
from nbxmpp.protocol import DataField
from nbxmpp.protocol import isResultNode
from nbxmpp.protocol import NodeProcessed
from nbxmpp.simplexml import Node
from nbxmpp.structs import StanzaHandler
from nbxmpp.const import InviteType
......@@ -301,11 +302,28 @@ class MUC:
except KeyError:
properties.voice_request = VoiceRequest(form=data_form)
nick = data_form['muc#roomnick'].value
jid = JID(data_form['muc#jid'].value)
except Exception:
log.warning('Invalid JID on voice request')
raise NodeProcessed
properties.voice_request = VoiceRequest(jid=jid,
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
def approve_voice_request(self, muc_jid, voice_request):
form = voice_request.form
form.type_ = 'submit'
form['muc#request_allow'].value = True
self._client.send(Message(to=muc_jid, payload=form))
def get_affiliation(self, jid, affiliation):
iq = Iq(typ='get', to=jid, queryNS=NS_MUC_ADMIN)
......@@ -48,7 +48,7 @@ CaptchaData = namedtuple('CaptchaData', 'form bob_data')
BobData = namedtuple('BobData', 'algo hash_ max_age data cid type')
VoiceRequest = namedtuple('VoiceRequest', 'form')
VoiceRequest = namedtuple('VoiceRequest', 'form jid nick')
MucUserData = namedtuple('MucUserData', 'affiliation jid nick role actor reason')
MucUserData.__new__.__defaults__ = (None, None, None, None, None)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment