Browse Source

fix(alerts): register alert_matrix module and harden dispatch

Addresses review feedback on the Matrix alert provider:
- Register alert_matrix.sh in core_modules.sh so the module actually
  resolves when alert.sh calls it (without this the call fails as an
  unknown command and no alert is ever sent).
- Use curl -sSL to follow redirects, matching the other alert modules
  (some homeservers/reverse proxies redirect the client API).
- Require matrixhomeserver to be set in the dispatch condition,
  consistent with the TEST-ALERT checks, to avoid building a broken
  URL when it is empty.
pull/4901/head
Daniel Gibbs 2 days ago
parent
commit
c13dbe5c95
Failed to extract signature
  1. 2
      lgsm/modules/alert.sh
  2. 2
      lgsm/modules/alert_matrix.sh
  3. 5
      lgsm/modules/core_modules.sh

2
lgsm/modules/alert.sh

@ -379,7 +379,7 @@ elif [ -z "${slacktoken}" ] && [ "${commandname}" == "TEST-ALERT" ]; then
fn_script_error "Slack token not set"
fi
if [ "${matrixalert}" == "on" ] && [ -n "${matrixtoken}" ] && [ -n "${matrixroom}" ]; then
if [ "${matrixalert}" == "on" ] && [ -n "${matrixhomeserver}" ] && [ -n "${matrixtoken}" ] && [ -n "${matrixroom}" ]; then
alert_matrix.sh
elif [ "${matrixalert}" != "on" ] && [ "${commandname}" == "TEST-ALERT" ]; then
fn_print_warn_nl "Matrix alerts not enabled"

2
lgsm/modules/alert_matrix.sh

@ -53,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 PUT \
matrixsend=$(curl --connect-timeout 10 -sSL -X PUT \
-H "Authorization: Bearer ${matrixtoken}" \
-H "Content-Type: application/json" \
-d "${json}" \

5
lgsm/modules/core_modules.sh

@ -590,6 +590,11 @@ alert_ifttt.sh() {
fn_fetch_module
}
alert_matrix.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
alert_ntfy.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module

Loading…
Cancel
Save