From c13dbe5c952094295b3a9f4f1cc55780a0facaab Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jul 2026 15:46:20 +0100 Subject: [PATCH] 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. --- lgsm/modules/alert.sh | 2 +- lgsm/modules/alert_matrix.sh | 2 +- lgsm/modules/core_modules.sh | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index e1578ad39..b256390df 100755 --- a/lgsm/modules/alert.sh +++ b/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" diff --git a/lgsm/modules/alert_matrix.sh b/lgsm/modules/alert_matrix.sh index dff3e0f5d..ab3f6e230 100755 --- a/lgsm/modules/alert_matrix.sh +++ b/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}" \ diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index ce1a6f6d4..8752cf76b 100755 --- a/lgsm/modules/core_modules.sh +++ b/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