Command-line Matrix notify tool and Flask application to provide a webhook for Matrix notifications.
Go to file
Ben 56a5ce3cef
Add exception wrapping nio.ErrorResponse
Fixes wrong usage nio.ErrorResponse as an exception.
2021-10-28 20:48:06 +02:00
.idea Update to Flask 2 and matrix-nio 2021-06-28 09:56:48 +02:00
.gitignore Add debug version of simple webhook-server 2019-07-18 14:45:03 +02:00
Dockerfile Replace datetime.fromisoformat with dateutil 2021-07-21 22:05:39 +02:00
LICENSE Update to Flask 2 and matrix-nio 2021-06-28 09:56:48 +02:00
README.md Update to Flask 2 and matrix-nio 2021-06-28 09:56:48 +02:00
common.py Add exception wrapping nio.ErrorResponse 2021-10-28 20:48:06 +02:00
config.yml.example Update to Flask 2 and matrix-nio 2021-06-28 09:56:48 +02:00
notify.py Add exception wrapping nio.ErrorResponse 2021-10-28 20:48:06 +02:00
requirements.txt Replace datetime.fromisoformat with dateutil 2021-07-21 22:05:39 +02:00
testrequest_gitlab.json Add better output for prometheus alerts 2020-09-27 17:55:20 +02:00
testrequest_prometheus.json Add better output for prometheus alerts 2020-09-27 17:55:20 +02:00
wmn.py Add exception wrapping nio.ErrorResponse 2021-10-28 20:48:06 +02:00

README.md

Webhook Matrix Notifier

Takes notifications via webhook, checks a secret and notifies a Matrix channel. Listens to HTTP only. Should be used behind a reverse-proxy with HTTPS.

An example configuration is at config.yml.example and the program always reads the configuration file config.yml.

Testing the Hook locally

First, start the webserver locally by env FLASK_APP=wmn.py flask run or have your IDE start it for you.
Then, send a POST request using curl.

GitLab

export CHANNEL_ENC=`python3 -c 'from urllib.parse import quote_plus; print(quote_plus("#channel:matrix.org"))'`
curl -i -X POST "http://localhost:5000/matrix?channel=${CHANNEL_ENC}" -H "X-Gitlab-Event: Push Hook" -H "X-Gitlab-Token: 123" -H "Content-Type: application/json" --data-binary @./testrequest_gitlab.json

The X-Gitlab-Token must correspond to the secret provided in config.yml

Prometheus

export CHANNEL_ENC=`python3 -c 'from urllib.parse import quote_plus; print(quote_plus("#channel:matrix.org"))'`
export WMN_SECRET=`python3 -c 'from urllib.parse import quote_plus; print(quote_plus("123"))'`
curl -i -X POST "http://localhost:5000/matrix?type=prometheus&secret=${WMN_SECRET}&channel=${CHANNEL_ENC}" -H "Content-Type: application/json" --data-binary @./testrequest_prometheus.json

The secret must be passed as a URI parameter here.