[Bps-public-commit] rt-extension-notifyslack branch, craig, updated. c034307428f8316bf536169c2edab3c914059e7c
Craig Kaiser
craig at bestpractical.com
Fri Nov 2 20:30:26 EDT 2018
The branch, craig has been updated
via c034307428f8316bf536169c2edab3c914059e7c (commit)
via daf2e2209313acb9adc8d9170617730385651793 (commit)
from d1854d241dbc92d8ddc655af908077b06ad31519 (commit)
Summary of changes:
etc/initialdata | 57 +++++++++++++++++++++++++++++++++++++++++++-
lib/RT/Action/NotifySlack.pm | 4 ----
2 files changed, 56 insertions(+), 5 deletions(-)
- Log -----------------------------------------------------------------
commit daf2e2209313acb9adc8d9170617730385651793
Author: Craig Kaiser <craig at bestpractical.com>
Date: Fri Nov 2 20:25:58 2018 -0400
Remove unused code
diff --git a/lib/RT/Action/NotifySlack.pm b/lib/RT/Action/NotifySlack.pm
index d629103..e7044ef 100644
--- a/lib/RT/Action/NotifySlack.pm
+++ b/lib/RT/Action/NotifySlack.pm
@@ -38,10 +38,6 @@ sub Commit {
my $ua = LWP::UserAgent->new;
$ua->timeout(15);
- my $ticket = $self->TicketObj;
- my $rt_url = RT->Config->Get( 'WebURL' )."Ticket/Display.html?id=".$ticket->id;
- my $txn = $self->TransactionObj;
-
# prevent infinite loop between RT and Slack
return 0 if $txn->Type eq 'SlackNotified';
commit c034307428f8316bf536169c2edab3c914059e7c
Author: Craig Kaiser <craig at bestpractical.com>
Date: Fri Nov 2 20:26:44 2018 -0400
Add scrip and template example for on create in intialdata
diff --git a/etc/initialdata b/etc/initialdata
index fe152b8..4dbe9af 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -1,4 +1,14 @@
-push @ScripActions, (
+use strict;
+use warnings;
+
+our @ScripActions;
+our @Scrips;
+our @Templates;
+
+########################################################################
+### ScripActions
+########################################################################
+ at ScripActions = (
{
Name => 'Notify Slack',
Description => 'Post ticket updates to slack channel',
@@ -6,3 +16,48 @@ push @ScripActions, (
Argument => '#general',
},
);
+
+########################################################################
+### Templates
+########################################################################
+ at 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,
+ \}
+ ],
+ \}
+ ]
+\}]
+});
+
+########################################################################
+### Scrips
+########################################################################
+ at Scrips = (
+ {
+ Description => 'On create alert slack channel.',
+ ScripCondition => 'On Create',
+ ScripAction => 'Notify Slack',
+ Template => 'Slack Create Message',
+ },
+);
+
+1;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list