Beispiel #1
0
    async def webhook(request):
        """Webhook to retrieve action calls."""
        action_call = request.json
        utils.check_version_compatibility(action_call.get("version"))
        try:
            result = await executor.run(action_call)
        except ActionExecutionRejection as e:
            logger.error(str(e))
            return create_error_response(str(e), e.action_name, 400)
        except ActionNotFoundRejection as e:
            logger.error(str(e))
            return create_error_response(str(e), e.action_name, 404)

        return create_ok_response(result)
Beispiel #2
0
 async def post(self):
     logging.debug(self.request.body)
     request_json = json_decode(self.request.body)
     utils.check_version_compatibility(request_json.get("version"))
     try:
         result = await self.process_actions(request_json)
         self.write(json_encode(result))
     except ActionExecutionRejection as e:
         logger.debug(e)
         body = {"error": e.message, "action_name": e.action_name}
         self.set_status(400)
         self.write(json_encode(body))
     except ActionNotFoundException as e:
         logger.error(e)
         body = {"error": e.message, "action_name": e.action_name}
         self.set_status(400)
         self.write(json_encode(body))
Beispiel #3
0
    async def webhook(request: Request) -> HTTPResponse:
        """Webhook to retrieve action calls."""
        action_call = request.json
        if action_call is None:
            body = {"error": "Invalid body request"}
            return response.json(body, status=400)

        utils.check_version_compatibility(action_call.get("version"))
        try:
            result = await executor.run(action_call)
        except ActionExecutionRejection as e:
            _logger.error(e)
            body = {"error": e.message, "action_name": e.action_name}
            return response.json(body, status=400)
        except ActionNotFoundException as e:
            _logger.error(e)
            body = {"error": e.message, "action_name": e.action_name}
            return response.json(body, status=404)

        return response.json(result, status=200)