Browse Source

fix(alerts): use PUT instead of POST for Matrix send-event endpoint

The Matrix Client-Server API requires PUT for
/_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}; sending
POST would be rejected by any spec-compliant homeserver (405), so
alerts would never actually send. Also documents that matrixroom
must be the internal room ID, not the human-readable room alias.
pull/4901/head
Daniel Gibbs 2 days ago
parent
commit
d53ed1cb61
Failed to extract signature
  1. 3
      lgsm/modules/alert_matrix.sh

3
lgsm/modules/alert_matrix.sh

@ -13,6 +13,7 @@ if [[ "${matrixbase}" != http://* ]] && [[ "${matrixbase}" != https://* ]]; then
fi
matrixbase="${matrixbase%/}"
# matrixroom must be the internal room ID (e.g. !abc123:matrix.org), not the room alias (#room:matrix.org).
matrixroomencoded="$(jq -rn --arg room "${matrixroom}" '$room|@uri')"
matrixtxnid="$(date +%s%N)"
matrixurl="${matrixbase}/_matrix/client/v3/rooms/${matrixroomencoded}/send/m.room.message/${matrixtxnid}"
@ -52,7 +53,7 @@ json="$(jq -cn --arg body "${message}" '{msgtype: "m.notice", body: $body}')"
fn_print_dots "Sending Matrix alert"
matrixsend=$(curl --connect-timeout 10 -sS -X POST \
matrixsend=$(curl --connect-timeout 10 -sS -X PUT \
-H "Authorization: Bearer ${matrixtoken}" \
-H "Content-Type: application/json" \
-d "${json}" \

Loading…
Cancel
Save