mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-01-16 08:05:57 +00:00
formatters: also get headers
This commit is contained in:
parent
ac7d1d9647
commit
4bcdb25c80
@ -79,9 +79,13 @@ curl -d '{"body":"new contrib from toto: [44](http://radio.localhost/map/#44)",
|
|||||||
```
|
```
|
||||||
(or localhost:4785 without docker)
|
(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
|
## Test room
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
"""Formatters for matrix webhook."""
|
"""Formatters for matrix webhook."""
|
||||||
|
|
||||||
|
|
||||||
def grafana(data):
|
def grafana(data, headers):
|
||||||
"""Pretty-print a grafana notification."""
|
"""Pretty-print a grafana notification."""
|
||||||
text = ""
|
text = ""
|
||||||
if "title" in data:
|
if "title" in data:
|
||||||
|
|||||||
@ -35,7 +35,9 @@ async def matrix_webhook(request):
|
|||||||
|
|
||||||
if "formatter" in request.rel_url.query:
|
if "formatter" in request.rel_url.query:
|
||||||
try:
|
try:
|
||||||
data = getattr(formatters, request.rel_url.query["formatter"])(data)
|
data = getattr(formatters, request.rel_url.query["formatter"])(
|
||||||
|
data, request.headers
|
||||||
|
)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return utils.create_json_response(
|
return utils.create_json_response(
|
||||||
HTTPStatus.BAD_REQUEST, "Unknown formatter"
|
HTTPStatus.BAD_REQUEST, "Unknown formatter"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user