Commit ceea0a8d authored by Philipp Hörist's avatar Philipp Hörist

AdHoc: Parse default action

parent 231904ad
Pipeline #6775 passed with stages
in 34 seconds
......@@ -96,11 +96,18 @@ class AdHoc(BaseModule):
notes.append(AdHocCommandNote(text=note.getData(),
type=type_))
default = None
actions_ = command.getTag('actions')
if actions_ is not None:
for action_ in actions_.getChildren():
actions.append(AdHocAction(action_.getName()))
default = actions_.getAttr('execute')
if default is not None:
default = AdHocAction(default)
if default not in actions:
default = None
yield AdHocCommand(
jid=str(response.getFrom()),
name=None,
......@@ -109,6 +116,7 @@ class AdHoc(BaseModule):
status=AdHocStatus(attrs['status']),
data=command.getTag('x', namespace=Namespace.DATA),
actions=actions,
default=default,
notes=notes)
except Exception as error:
raise MalformedStanzaError(str(error), response)
......
......@@ -396,14 +396,14 @@ class DiscoIdentity(namedtuple('DiscoIdentity', 'category type name lang')):
return hash(str(self))
class AdHocCommand(namedtuple('AdHocCommand', 'jid node name sessionid status data actions notes')):
class AdHocCommand(namedtuple('AdHocCommand', 'jid node name sessionid status data actions default notes')):
__slots__ = []
def __new__(cls, jid, node, name, sessionid=None, status=None,
data=None, actions=None, notes=None):
data=None, actions=None, default=None, notes=None):
return super(AdHocCommand, cls).__new__(cls, jid, node, name, sessionid,
status, data, actions, notes)
status, data, actions, default, notes)
@property
def is_completed(self):
......
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