From be14f0cc52a748134e2f1e77a4d10b11e8ff8b25 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Wed, 15 Jul 2015 20:52:06 -0600 Subject: XEP_0050: Form not iterable in command Cannot pass in a form into the initial command and have it show up in the payload of the session. Line 344 makes this possible when following the standard workflow. --- sleekxmpp/plugins/xep_0050/adhoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleekxmpp/plugins/xep_0050/adhoc.py b/sleekxmpp/plugins/xep_0050/adhoc.py index e5594c3f..5f4ea94c 100644 --- a/sleekxmpp/plugins/xep_0050/adhoc.py +++ b/sleekxmpp/plugins/xep_0050/adhoc.py @@ -101,7 +101,7 @@ class XEP_0050(BasePlugin): self._handle_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._handle_command_start, -- cgit v1.2.3 From 4a24f58be26f8d5040dab2ddc3428bd989296fdb Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Thu, 3 Sep 2015 10:15:41 -0600 Subject: XEP0050: Add support for payload in completed response When sending the command to complete the task, the adhoc plugin does not provide the ability to send a payload from the _handle_command_complete method. --- sleekxmpp/plugins/xep_0050/adhoc.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sleekxmpp/plugins/xep_0050/adhoc.py b/sleekxmpp/plugins/xep_0050/adhoc.py index 5f4ea94c..7ab659f4 100644 --- a/sleekxmpp/plugins/xep_0050/adhoc.py +++ b/sleekxmpp/plugins/xep_0050/adhoc.py @@ -425,12 +425,25 @@ class XEP_0050(BasePlugin): 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['command']['node'] = node iq['command']['sessionid'] = sessionid iq['command']['actions'] = [] iq['command']['status'] = 'completed' iq['command']['notes'] = session['notes'] + + for item in payload: + iq['command'].append(item) + iq.send() else: raise XMPPError('item-not-found') -- cgit v1.2.3 From ffb2b6bc0464a9646d4b4bca3943d3a89dfc13a6 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Sat, 12 Sep 2015 20:08:21 -0600 Subject: Update test_stream_xep_0050.py Fix Unit Test for adhoc 50 stream. --- tests/test_stream_xep_0050.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_stream_xep_0050.py b/tests/test_stream_xep_0050.py index 261a0057..8fd09a8d 100644 --- a/tests/test_stream_xep_0050.py +++ b/tests/test_stream_xep_0050.py @@ -120,6 +120,7 @@ class TestAdHocCommands(SleekTest): def handle_form(form, session): results.append(form['values']['foo']) + session['payload'] = None form = self.xmpp['xep_0004'].makeForm('form') form.addField(var='foo', ftype='text-single', label='Foo') @@ -192,6 +193,7 @@ class TestAdHocCommands(SleekTest): def handle_step2(form, session): results.append(form['values']['bar']) + session['payload'] = None def handle_step1(form, session): results.append(form['values']['foo']) @@ -427,6 +429,7 @@ class TestAdHocCommands(SleekTest): def handle_form(forms, session): for form in forms: results.append(form['values']['FORM_TYPE']) + session['payload'] = None form1 = self.xmpp['xep_0004'].makeForm('form') form1.addField(var='FORM_TYPE', ftype='hidden', value='form_1') -- cgit v1.2.3