fix(notifications): update Matrix sender to comply with Matrix API (#21659)
Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Costa Tsaousis committed
Jan 28, 2026 at 09:50 UTC
413d783682c85370f0a31fcf97d84678a56c552b
1 file changed
+4
-3
src/health/notifications/alarm-notify.sh.in
+4
-3
@@ -2168,7 +2168,7 @@ send_awssns() {
2168
# Matrix sender
2169
2170
send_matrix() {
2171
- local homeserver="${1}" webhook accesstoken rooms="${2}" httpcode sent=0 payload
2171
+ local homeserver="${1}" webhook accesstoken rooms="${2}" httpcode sent=0 payload txnid
2172
2173
[ "${SEND_MATRIX}" != "YES" ] && return 1
2174
[ -z "${MATRIX_ACCESSTOKEN}" ] && return 1
@@ -2183,7 +2183,8 @@ send_matrix() {
2183
esac
2184
2185
for room in ${rooms}; do
2186
- webhook="$homeserver/_matrix/client/r0/rooms/$(urlencode $room)/send/m.room.message?access_token=$accesstoken"
2186
+ txnid="nd_$(date +%s)_$$_$RANDOM"
2187
+ webhook="$homeserver/_matrix/client/r0/rooms/$(urlencode $room)/send/m.room.message/$txnid"
2188
payload="$(
2189
cat <<EOF
2190
{
@@ -2195,7 +2196,7 @@ send_matrix() {
2196
EOF
2197
)"
2198
2198
- httpcode=$(docurl -X POST --data "${payload}" "${webhook}")
2199
+ httpcode=$(docurl -X PUT -H "Authorization: Bearer ${accesstoken}" -H "Content-Type: application/json" --data "${payload}" "${webhook}")
2200
if [ "${httpcode}" == "200" ]; then
2201
info "sent Matrix notification to '${room}' for ${notification_description}"
2202
sent=$((sent + 1))