Collapse initial payload to a single stanza instead of a list if only one stanza is found.

This commit is contained in:
Lance Stout 2012-04-30 11:16:10 -07:00
parent ad5b61de50
commit a9acff5294
2 changed files with 4 additions and 1 deletions

View file

@ -218,6 +218,9 @@ class XEP_0050(BasePlugin):
for stanza in iq['command']['substanzas']: for stanza in iq['command']['substanzas']:
payload.append(stanza) payload.append(stanza)
if len(payload) == 1:
payload = payload[0]
interfaces = set([item.plugin_attrib for item in payload]) interfaces = set([item.plugin_attrib for item in payload])
payload_classes = set([item.__class__ for item in payload]) payload_classes = set([item.__class__ for item in payload])

View file

@ -35,7 +35,7 @@ class TestAdHocCommands(SleekTest):
logging.debug(initial) logging.debug(initial)
new_payload = TestPayload() new_payload = TestPayload()
if initial: if initial:
new_payload['bar'] = 'Received: %s' % initial[0]['bar'] new_payload['bar'] = 'Received: %s' % initial['bar']
else: else:
new_payload['bar'] = 'Failed' new_payload['bar'] = 'Failed'