aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-04-12 11:03:14 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-04-15 09:11:25 +0200
commit2a232ad2f5eef4b60c97306ef731bc5883bf5cfb (patch)
tree15d912e84a700ca590ba56cf621972696ca0bb5b /mod
parent9dfa11eac534019d08a5cfa289d7cde0f22c2a92 (diff)
mod/notification-matrix: generate JSON with :serializerouteros-7.13-7
Diffstat (limited to 'mod')
-rw-r--r--mod/notification-matrix.rsc24
1 files changed, 11 insertions, 13 deletions
diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc
index 12a0e33..3e3a33e 100644
--- a/mod/notification-matrix.rsc
+++ b/mod/notification-matrix.rsc
@@ -40,12 +40,11 @@
:if ([ :typeof $Message ] = "array" ) do={
:do {
/tool/fetch check-certificate=yes-without-crl output=none \
- http-header-field=($Message->"headers") http-method=post \
- ("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \
- "/send/m.room.message?access_token=" . $Message->"accesstoken") \
- http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Message->"plain" . "\"," . \
- "\"format\": \"org.matrix.custom.html\", \"formatted_body\": \"" . \
- $Message->"formatted" . "\" }") as-value;
+ http-header-field=($Message->"headers") http-method=post \
+ http-data=[ :serialize to=json { "msgtype"="m.text"; "body"=($Message->"plain");
+ "format"="org.matrix.custom.html"; "formatted_body"=($Message->"formatted") } ] \
+ ("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \
+ "/send/m.room.message?access_token=" . $Message->"accesstoken") as-value;
:set ($MatrixQueue->$Id);
} on-error={
$LogPrint debug $0 ("Sending queued Matrix message failed.");
@@ -133,12 +132,11 @@
:do {
/tool/fetch check-certificate=yes-without-crl output=none \
- http-header-field=$Headers http-method=post \
- ("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \
- "/send/m.room.message?access_token=" . $AccessToken) \
- http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Plain . "\"," . \
- "\"format\": \"org.matrix.custom.html\", \"formatted_body\": \"" . \
- $Formatted . "\" }") as-value;
+ http-header-field=$Headers http-method=post \
+ http-data=[ :serialize to=json { "msgtype"="m.text"; "body"=$Plain;
+ "format"="org.matrix.custom.html"; "formatted_body"=$Formatted } ] \
+ ("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \
+ "/send/m.room.message?access_token=" . $AccessToken) as-value;
} on-error={
$LogPrint info $0 ("Failed sending Matrix notification! Queuing...");
@@ -214,7 +212,7 @@
:do {
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
http-header-field=({ [ $FetchUserAgentStr $0 ] }) http-method=post \
- http-data=("{\"type\":\"m.login.password\", \"user\":\"" . $User . "\", \"password\":\"" . $Pass . "\"}") \
+ http-data=[ :serialize to=json { "type"="m.login.password"; "user"=$User; "password"=$Pass } ] \
("https://" . $MatrixHomeServer . "/_matrix/client/r0/login") as-value ]->"data");
:set MatrixAccessToken ([ :deserialize from=json value=$Data ]->"access_token");
$LogPrint debug $0 ("Access token is: " . $MatrixAccessToken);