forked from platypush/platypush
[request] The action name can be specified either on action
or name
.
This is for UI compatibility purposes.
This commit is contained in:
parent
05b1fcd43a
commit
5a7068501a
2 changed files with 5 additions and 3 deletions
|
@ -64,12 +64,13 @@ class Request(Message):
|
|||
msg = super().parse(msg)
|
||||
args = {
|
||||
'target': msg.get('target', Config.get('device_id')),
|
||||
'action': msg['action'],
|
||||
'action': msg.get('action', msg.get('name')),
|
||||
'args': msg.get('args', {}),
|
||||
'id': msg['id'] if 'id' in msg else cls._generate_id(),
|
||||
'timestamp': msg['_timestamp'] if '_timestamp' in msg else time.time(),
|
||||
}
|
||||
|
||||
assert args.get('action'), 'No action specified in the request'
|
||||
if 'origin' in msg:
|
||||
args['origin'] = msg['origin']
|
||||
if 'token' in msg:
|
||||
|
|
|
@ -286,9 +286,10 @@ class ProceduresPlugin(RunnablePlugin, ProcedureEntityManager):
|
|||
@classmethod
|
||||
def _serialize_action(cls, data: Union[Iterable, Dict]) -> Union[Dict, List]:
|
||||
if isinstance(data, dict):
|
||||
if data.get('action'):
|
||||
name = data.get('action', data.get('name'))
|
||||
if name:
|
||||
return {
|
||||
'action': data['action'],
|
||||
'action': name,
|
||||
**({'args': data['args']} if data.get('args') else {}),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue