diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index 7a55e65429..8dda18eb7d 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -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: diff --git a/platypush/plugins/procedures/__init__.py b/platypush/plugins/procedures/__init__.py index 3e66f7631e..cffd2f65f1 100644 --- a/platypush/plugins/procedures/__init__.py +++ b/platypush/plugins/procedures/__init__.py @@ -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 {}), }