Merge pull request #397 from rerobins/xep_0050_updates
Xep 0050 updates
This commit is contained in:
commit
4305eddb4f
@ -101,7 +101,7 @@ class XEP_0050(BasePlugin):
|
|||||||
self._handle_command))
|
self._handle_command))
|
||||||
|
|
||||||
register_stanza_plugin(Iq, Command)
|
register_stanza_plugin(Iq, Command)
|
||||||
register_stanza_plugin(Command, Form)
|
register_stanza_plugin(Command, Form, iterable=True)
|
||||||
|
|
||||||
self.xmpp.add_event_handler('command_execute',
|
self.xmpp.add_event_handler('command_execute',
|
||||||
self._handle_command_start,
|
self._handle_command_start,
|
||||||
@ -425,12 +425,25 @@ class XEP_0050(BasePlugin):
|
|||||||
|
|
||||||
del self.sessions[sessionid]
|
del self.sessions[sessionid]
|
||||||
|
|
||||||
|
payload = session['payload']
|
||||||
|
if payload is None:
|
||||||
|
payload = []
|
||||||
|
if not isinstance(payload, list):
|
||||||
|
payload = [payload]
|
||||||
|
|
||||||
|
for item in payload:
|
||||||
|
register_stanza_plugin(Command, item.__class__, iterable=True)
|
||||||
|
|
||||||
iq.reply()
|
iq.reply()
|
||||||
iq['command']['node'] = node
|
iq['command']['node'] = node
|
||||||
iq['command']['sessionid'] = sessionid
|
iq['command']['sessionid'] = sessionid
|
||||||
iq['command']['actions'] = []
|
iq['command']['actions'] = []
|
||||||
iq['command']['status'] = 'completed'
|
iq['command']['status'] = 'completed'
|
||||||
iq['command']['notes'] = session['notes']
|
iq['command']['notes'] = session['notes']
|
||||||
|
|
||||||
|
for item in payload:
|
||||||
|
iq['command'].append(item)
|
||||||
|
|
||||||
iq.send()
|
iq.send()
|
||||||
else:
|
else:
|
||||||
raise XMPPError('item-not-found')
|
raise XMPPError('item-not-found')
|
||||||
|
@ -120,6 +120,7 @@ class TestAdHocCommands(SleekTest):
|
|||||||
|
|
||||||
def handle_form(form, session):
|
def handle_form(form, session):
|
||||||
results.append(form.get_values()['foo'])
|
results.append(form.get_values()['foo'])
|
||||||
|
session['payload'] = None
|
||||||
|
|
||||||
form = self.xmpp['xep_0004'].makeForm('form')
|
form = self.xmpp['xep_0004'].makeForm('form')
|
||||||
form.addField(var='foo', ftype='text-single', label='Foo')
|
form.addField(var='foo', ftype='text-single', label='Foo')
|
||||||
@ -192,6 +193,7 @@ class TestAdHocCommands(SleekTest):
|
|||||||
|
|
||||||
def handle_step2(form, session):
|
def handle_step2(form, session):
|
||||||
results.append(form.get_values()['bar'])
|
results.append(form.get_values()['bar'])
|
||||||
|
session['payload'] = None
|
||||||
|
|
||||||
def handle_step1(form, session):
|
def handle_step1(form, session):
|
||||||
results.append(form.get_values()['foo'])
|
results.append(form.get_values()['foo'])
|
||||||
@ -427,6 +429,7 @@ class TestAdHocCommands(SleekTest):
|
|||||||
def handle_form(forms, session):
|
def handle_form(forms, session):
|
||||||
for form in forms:
|
for form in forms:
|
||||||
results.append(form.get_values()['FORM_TYPE'])
|
results.append(form.get_values()['FORM_TYPE'])
|
||||||
|
session['payload'] = None
|
||||||
|
|
||||||
form1 = self.xmpp['xep_0004'].makeForm('form')
|
form1 = self.xmpp['xep_0004'].makeForm('form')
|
||||||
form1.addField(var='FORM_TYPE', ftype='hidden', value='form_1')
|
form1.addField(var='FORM_TYPE', ftype='hidden', value='form_1')
|
||||||
|
Loading…
Reference in New Issue
Block a user