[Bps-public-commit] rt-extension-notifyslack branch, master, updated. d4cc8ded58d6f21bcef29397d2e2055199657774
? sunnavy
sunnavy at bestpractical.com
Thu Sep 3 09:20:01 EDT 2020
The branch, master has been updated
via d4cc8ded58d6f21bcef29397d2e2055199657774 (commit)
from fe8d3da0b4f436354eb0898f9e3bd1608f7a8959 (commit)
Summary of changes:
etc/initialdata | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
- Log -----------------------------------------------------------------
commit d4cc8ded58d6f21bcef29397d2e2055199657774
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Sep 3 19:00:35 2020 +0800
Generate json string from perl structure to make it 100% valid
Previously we didn't escape ticket subject or transaction content, which
could cause json to be invalid(e.g. if it contains double quotes).
Besides that, previous code also used single quotes and trailing commas,
which are not valid either(it worked though probably because slack uses
a tolerant parser).
diff --git a/etc/initialdata b/etc/initialdata
index 4dbe9af..26df325 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -24,28 +24,29 @@ our @Templates;
Name => 'Slack Create Message',
Description => 'Send a message to slack channel on ticket create.',
Content =>q[
-\{
- "attachments": [
- \{
- "color": "#36a64f",
- "title": "#{$Ticket->Id} {$Ticket->Subject} Created:",
- "title_link": "{RT->Config->Get( 'WebURL' )}Ticket/Display.html?id={$Ticket->Id}",
- "text": "{$Transaction->Content}",
- "fields": [
- \{
- "title" : 'Queue',
- "value" : "{$Ticket->QueueObj->Name}",
- "short" : false,
- \},
- \{
- "title" : 'Owner',
- "value" : "{$Ticket->OwnerObj->Name}",
- "short" : false,
- \}
- ],
- \}
- ]
-\}]
+{
+ my $payload = {
+ attachments => [
+ { "color" => "#36a64f",
+ "title" => '#' . $Ticket->Id . ' ' . $Ticket->Subject . ' Created:',
+ "title_link" => RT->Config->Get('WebURL') . 'Ticket/Display.html?id=' . $Ticket->Id,
+ "text" => $Transaction->Content,
+ "fields" => [
+ { "title" => "Queue",
+ "value" => $Ticket->QueueObj->Name,
+ "short" => 0,
+ },
+ { "title" => "Owner",
+ "value" => $Ticket->OwnerObj->Name,
+ "short" => 0,
+ },
+ ],
+ },
+ ],
+ };
+ JSON::to_json($payload);
+}
+]
});
########################################################################
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list