aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-28 22:54:23 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-04-01 22:45:35 +0200
commitbb237dcef3fea8c5a6988cc52b2a0360078faad8 (patch)
tree15498f708abae4b98e34c3a8791654be93ed7749 /mod
parent29bcbc4db9d39573e8c8017e75eea4df7f603c2c (diff)
mod/notification-matrix: use :deserialize ...
... instead of $ParseJson. This requires RouterOS 7.13.
Diffstat (limited to 'mod')
-rw-r--r--mod/notification-matrix.rsc8
1 files changed, 4 insertions, 4 deletions
diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc
index aa95841..8234779 100644
--- a/mod/notification-matrix.rsc
+++ b/mod/notification-matrix.rsc
@@ -4,6 +4,8 @@
# Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
+# requires RouterOS, version=7.13
+#
# send notifications via Matrix
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-matrix.md
@@ -183,9 +185,7 @@
:local User [ :tostr $1 ];
:local Pass [ :tostr $2 ];
- :global CharacterReplace;
:global LogPrint;
- :global ParseJson;
:global MatrixAccessToken;
:global MatrixHomeServer;
@@ -194,7 +194,7 @@
:do {
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
("https://" . $Domain . "/.well-known/matrix/client") as-value ]->"data");
- :set MatrixHomeServer ([ $ParseJson ([ $ParseJson [ $CharacterReplace $Data " " "" ] ]->"m.homeserver") ]->"base_url");
+ :set MatrixHomeServer ([ :deserialize from=json value=$Data ]->"m.homeserver"->"base_url");
$LogPrint debug $0 ("Home server is: " . $MatrixHomeServer);
} on-error={
$LogPrint error $0 ("Failed getting home server!");
@@ -209,7 +209,7 @@
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
http-method=post http-data=("{\"type\":\"m.login.password\", \"user\":\"" . $User . "\", \"password\":\"" . $Pass . "\"}") \
("https://" . $MatrixHomeServer . "/_matrix/client/r0/login") as-value ]->"data");
- :set MatrixAccessToken ([ $ParseJson $Data ]->"access_token");
+ :set MatrixAccessToken ([ :deserialize from=json value=$Data ]->"access_token");
$LogPrint debug $0 ("Access token is: " . $MatrixAccessToken);
} on-error={
$LogPrint error $0 ("Failed logging in (and getting access token)!");