diff --git a/README.md b/README.md index c4c31d1..62f7dbd 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,13 @@ curl -d '{"body":"new contrib from toto: [44](http://radio.localhost/map/#44)", ``` (or localhost:4785 without docker) -### Grafana +### For Github -Add a webhook with an URL like ending with `?formatter=grafana&key=API_KEY' +Add a JSON webhook with `?formatter=github`, and put the `API_KEY` as secret + +### For Grafana + +Add a webhook with an URL ending with `?formatter=grafana&key=API_KEY' ## Test room diff --git a/matrix_webhook/formatters.py b/matrix_webhook/formatters.py index 1e4600e..bec0979 100644 --- a/matrix_webhook/formatters.py +++ b/matrix_webhook/formatters.py @@ -1,7 +1,7 @@ """Formatters for matrix webhook.""" -def grafana(data): +def grafana(data, headers): """Pretty-print a grafana notification.""" text = "" if "title" in data: diff --git a/matrix_webhook/handler.py b/matrix_webhook/handler.py index 6ba9c59..ee48710 100644 --- a/matrix_webhook/handler.py +++ b/matrix_webhook/handler.py @@ -35,7 +35,9 @@ async def matrix_webhook(request): if "formatter" in request.rel_url.query: try: - data = getattr(formatters, request.rel_url.query["formatter"])(data) + data = getattr(formatters, request.rel_url.query["formatter"])( + data, request.headers + ) except AttributeError: return utils.create_json_response( HTTPStatus.BAD_REQUEST, "Unknown formatter"