From dfab5305252301e296459b6c2968423bc603f2ad Mon Sep 17 00:00:00 2001 From: thomcatdotrocks <37344783+thomcatdotrocks@users.noreply.github.com> Date: Fri, 4 Sep 2020 09:38:19 -0500 Subject: [PATCH] Matrix txnid fix (#12057) * Fix Matrix alerting txnid This fixes the issue I brought up in #12018. I can confirm that I now get a new message from the LibreNMS bot every time I test my Matrix transport. * Update AUTHORS.md --- AUTHORS.md | 1 + LibreNMS/Alert/Transport/Matrix.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index d3673e27de..c550821711 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -215,6 +215,7 @@ LibreNMS contributors: - Pavle Obradovic (pobradovic08) - Jason Cheng (jasoncheng7115) - Daniel Baeza (TheGreatDoc) +- Thom Cleary (thomcatdotrocks) Observium was written by: - Adam Armstrong diff --git a/LibreNMS/Alert/Transport/Matrix.php b/LibreNMS/Alert/Transport/Matrix.php index f6b2c220c3..2fea77c0a6 100644 --- a/LibreNMS/Alert/Transport/Matrix.php +++ b/LibreNMS/Alert/Transport/Matrix.php @@ -43,9 +43,10 @@ class Matrix extends Transport { $request_opts = []; $request_heads = []; + $txnid = rand(1111, 9999) . time(); $server = preg_replace('/\/$/', '', $server); - $host = $server."/_matrix/client/r0/rooms/".urlencode($room)."/send/m.room.message/".$obj['uid']; + $host = $server."/_matrix/client/r0/rooms/".urlencode($room)."/send/m.room.message/".$txnid; $request_heads['Authorization'] = "Bearer $authtoken"; $request_heads['Content-Type'] = "application/json";