aboutsummaryrefslogtreecommitdiffstats
path: root/mod/notification-matrix.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'mod/notification-matrix.rsc')
-rw-r--r--mod/notification-matrix.rsc43
1 files changed, 20 insertions, 23 deletions
diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc
index 3e3a33e..196633a 100644
--- a/mod/notification-matrix.rsc
+++ b/mod/notification-matrix.rsc
@@ -76,6 +76,7 @@
:global EitherOr;
:global FetchUserAgentStr;
:global LogPrint;
+ :global ProtocolStrip;
:global SymbolForNotification;
:local PrepareText do={
@@ -86,21 +87,15 @@
}
:local Return "";
- :local Chars {
- "plain"={ "\\"; "\""; "\n" };
- "format"={ "\\"; "\""; "\n"; "&"; "<"; ">" };
- }
- :local Subs {
- "plain"={ "\\\\"; "\\\""; "\\n" };
- "format"={ "\\\\"; "&quot;"; "<br/>"; "&amp;"; "&lt;"; "&gt;" };
- }
+ :local Chars { "\""; "\n"; "&"; "<"; ">" };
+ :local Subs { "&quot;"; "<br/>"; "&amp;"; "&lt;"; "&gt;" };
:for I from=0 to=([ :len $Input ] - 1) do={
:local Char [ :pick $Input $I ];
- :local Replace [ :find ($Chars->$2) $Char ];
+ :local Replace [ :find $Chars $Char ];
:if ([ :typeof $Replace ] = "num") do={
- :set Char ($Subs->$2->$Replace);
+ :set Char ($Subs->$Replace);
}
:set Return ($Return . $Char);
}
@@ -117,17 +112,18 @@
}
:local Headers ({ [ $FetchUserAgentStr ($Notification->"origin") ] });
- :local Plain [ $PrepareText ("## [" . $IdentityExtra . $Identity . "] " . \
- ($Notification->"subject") . "\n```\n" . ($Notification->"message") . "\n```") "plain" ];
+ :local Plain ("## [" . $IdentityExtra . $Identity . "] " . \
+ ($Notification->"subject") . "\n```\n" . ($Notification->"message") . "\n```");
:local Formatted ("<h2>" . [ $PrepareText ("[" . $IdentityExtra . $Identity . "] " . \
- ($Notification->"subject")) "format" ] . "</h2>" . "<pre><code>" . \
- [ $PrepareText ($Notification->"message") "format" ] . "</code></pre>");
+ ($Notification->"subject")) ] . "</h2>" . "<pre><code>" . \
+ [ $PrepareText ($Notification->"message") ] . "</code></pre>");
:if ([ :len ($Notification->"link") ] > 0) do={
- :set Plain ($Plain . "\\n" . [ $SymbolForNotification "link" ] . \
- [ $PrepareText ("[" . $Notification->"link" . "](" . $Notification->"link" . ")") "plain" ]);
+ :local Label [ $ProtocolStrip ($Notification->"link") ];
+ :set Plain ($Plain . "\n" . [ $SymbolForNotification "link" ] . \
+ "[" . $Label . "](" . $Notification->"link" . ")");
:set Formatted ($Formatted . "<br/>" . [ $SymbolForNotification "link" ] . \
- "<a href=\\\"" . [ $PrepareText ($Notification->"link") "format" ] . "\\\">" . \
- [ $PrepareText ($Notification->"link") "format" ] . "</a>");
+ "<a href=\"" . [ $PrepareText ($Notification->"link") ] . "\">" . \
+ [ $PrepareText $Label ] . "</a>");
}
:do {
@@ -143,11 +139,12 @@
:if ([ :typeof $MatrixQueue ] = "nothing") do={
:set MatrixQueue ({});
}
- :local Text ([ $SymbolForNotification "alarm-clock" ] . \
- "This message was queued since " . [ /system/clock/get date ] . \
- " " . [ /system/clock/get time ] . " and may be obsolete.");
- :set Plain ($Plain . "\\n" . $Text);
- :set Formatted ($Formatted . "<br/>" . $Text);
+ :local Symbol [ $SymbolForNotification "alarm-clock" ];
+ :local DateTime ([ /system/clock/get date ] . " " . [ /system/clock/get time ]);
+ :set Plain ($Plain . "\n" . $Symbol . "This message was queued since *" . \
+ $DateTime . "* and may be obsolete.");
+ :set Formatted ($Formatted . "<br/>" . $Symbol . "This message was queued since <em>" . \
+ $DateTime . "</em> and may be obsolete.");
:set ($MatrixQueue->[ :len $MatrixQueue ]) { headers=$Headers; \
accesstoken=$AccessToken; homeserver=$HomeServer; room=$Room; \
plain=$Plain; formatted=$Formatted };