[Bps-public-commit] rt-extension-notifyslack branch, master, updated. 1685f84705a60b2e59a91fa1072f6b8fb8f4c127

Maureen Mirville maureen at bestpractical.com
Thu Jul 19 12:19:22 EDT 2018


The branch, master has been updated
       via  1685f84705a60b2e59a91fa1072f6b8fb8f4c127 (commit)
       via  3a40e833ac3393edd5568eee5fd5e6b7df833419 (commit)
       via  aefe0bd6ae4fddbeab0caa72f2e8554485a92879 (commit)
      from  144a9bfe7dc9da796632f77ccc58093197482e45 (commit)

Summary of changes:
 README                          | 38 +++++++++++++++++++++--------
 lib/RT/Action/NotifySlack.pm    |  4 +++
 lib/RT/Extension/NotifySlack.pm | 54 ++++++++++++++++++++++++++++++++---------
 3 files changed, 74 insertions(+), 22 deletions(-)

- Log -----------------------------------------------------------------
commit aefe0bd6ae4fddbeab0caa72f2e8554485a92879
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Wed Jul 18 21:09:11 2018 -0400

    Correct extension name in docs

diff --git a/README b/README
index f582de2..565bd1a 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 NAME
-    RT-Extension-Slack-Integration - [One line description of module's
+    RT-Extension-NotifySlack - [One line description of module's
     purpose here]
 
 DESCRIPTION
@@ -20,7 +20,7 @@ INSTALLATION
     Edit your /opt/rt4/etc/RT_SiteConfig.pm
         Add this line:
 
-            Plugin('RT::Extension::Slack::Integration');
+            Plugin('RT::Extension::NotifySlack');
 
     Clear your mason cache
             rm -rf /opt/rt4/var/mason_data/obj
@@ -31,9 +31,9 @@ AUTHOR
     Best Practical Solutions, LLC <modules at bestpractical.com>
 
     All bugs should be reported via email to
-        bug-RT-Extension-Slack-Integration at rt.cpan.org
+        bug-RT-Extension-NotifySlack at rt.cpan.org
     or via the web at
-        http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Slack-Integration
+        http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-NotifySlack
 LICENSE AND COPYRIGHT
     This software is Copyright (c) 2018 by Best Practical Solutions, LLC
 
diff --git a/lib/RT/Extension/NotifySlack.pm b/lib/RT/Extension/NotifySlack.pm
index eb8f239..ee77705 100644
--- a/lib/RT/Extension/NotifySlack.pm
+++ b/lib/RT/Extension/NotifySlack.pm
@@ -1,12 +1,12 @@
 use strict;
 use warnings;
-package RT::Extension::Slack::Integration;
+package RT::Extension::NotifySlack;
 
 our $VERSION = '0.01';
 
 =head1 NAME
 
-RT-Extension-Slack-Integration - [One line description of module's purpose here]
+RT-Extension-NotifySlack - [One line description of module's purpose here]
 
 =head1 DESCRIPTION
 
@@ -35,7 +35,7 @@ May need root permissions
 
 Add this line:
 
-    Plugin('RT::Extension::Slack::Integration');
+    Plugin('RT::Extension::NotifySlack');
 
 =item Clear your mason cache
 
@@ -50,15 +50,15 @@ Add this line:
 Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>
 
 =for html <p>All bugs should be reported via email to <a
-href="mailto:bug-RT-Extension-Slack-Integration at rt.cpan.org">bug-RT-Extension-Slack-Integration at rt.cpan.org</a>
+href="mailto:bug-RT-Extension-NotifySlack at rt.cpan.org">bug-RT-Extension-NotifySlack at rt.cpan.org</a>
 or via the web at <a
-href="http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Slack-Integration">rt.cpan.org</a>.</p>
+href="http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-NotifySlack">rt.cpan.org</a>.</p>
 
 =for text
     All bugs should be reported via email to
-        bug-RT-Extension-Slack-Integration at rt.cpan.org
+        bug-RT-Extension-NotifySlack at rt.cpan.org
     or via the web at
-        http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Slack-Integration
+        http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-NotifySlack
 
 =head1 LICENSE AND COPYRIGHT
 

commit 3a40e833ac3393edd5568eee5fd5e6b7df833419
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Thu Jul 19 09:25:43 2018 -0400

    Update and add configuration information to docs

diff --git a/README b/README
index 565bd1a..49d169b 100644
--- a/README
+++ b/README
@@ -1,15 +1,13 @@
 NAME
-    RT-Extension-NotifySlack - [One line description of module's
-    purpose here]
+    RT-Extension-NotifySlack - RT ScripAction Slack integration
 
 DESCRIPTION
-    [Why would someone install this extension? What does it do? What problem
-    does it solve?]
+    This extension provides the following Slack functionality with RT:
 
-RT VERSION
-    Works with RT [What versions of RT is this known to work with?]
+    * post ticket updates to desired Slack channels
 
-    [Make sure to use requires_rt and rt_too_new in Makefile.PL]
+RT VERSION
+    Works with RT 4.4
 
 INSTALLATION
     perl Makefile.PL
@@ -17,6 +15,14 @@ INSTALLATION
     make install
         May need root permissions
 
+    make initdb
+        See the CONFIGURATION section below before running this command.
+
+        Only run this the first time you install this module.
+
+        If you run this twice, you may end up with duplicate data in your
+        database.
+
     Edit your /opt/rt4/etc/RT_SiteConfig.pm
         Add this line:
 
@@ -27,6 +33,18 @@ INSTALLATION
 
     Restart your webserver
 
+CONFIGURATION
+    You must add the desired Slack channels and webhook URLs to the RT
+    %SlackWebHookUrls config value in RT_SiteConfig.pm. These values can be
+    retrieved from Slack's API Incoming Webhooks configuration settings.
+
+    The 'Notify Slack' ScripAction posts to one Slack channel. The default
+    Slack channel is currently set to #general. You can update this in the
+    initialdata file by changing the 'Notify Slack' ScripAction Argument to
+    the desired Slack channel ( be sure to include the '#' when indicating
+    the channel name ). To post to additional Slack channels, copy the
+    ScripAction giving it a new Name and Argument.
+
 AUTHOR
     Best Practical Solutions, LLC <modules at bestpractical.com>
 
diff --git a/lib/RT/Extension/NotifySlack.pm b/lib/RT/Extension/NotifySlack.pm
index ee77705..385a7a1 100644
--- a/lib/RT/Extension/NotifySlack.pm
+++ b/lib/RT/Extension/NotifySlack.pm
@@ -6,18 +6,17 @@ our $VERSION = '0.01';
 
 =head1 NAME
 
-RT-Extension-NotifySlack - [One line description of module's purpose here]
+RT-Extension-NotifySlack - RT ScripAction Slack integration
 
 =head1 DESCRIPTION
 
-[Why would someone install this extension? What does it do? What problem
-does it solve?]
+This extension provides the following Slack functionality with RT:
 
-=head1 RT VERSION
+* post ticket updates to desired Slack channels
 
-Works with RT [What versions of RT is this known to work with?]
+=head1 RT VERSION
 
-[Make sure to use requires_rt and rt_too_new in Makefile.PL]
+Works with RT 4.4
 
 =head1 INSTALLATION
 
@@ -31,6 +30,15 @@ Works with RT [What versions of RT is this known to work with?]
 
 May need root permissions
 
+=item C<make initdb>
+
+See the CONFIGURATION section below before running this command.
+
+Only run this the first time you install this module.
+
+If you run this twice, you may end up with duplicate data
+in your database.
+
 =item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
 
 Add this line:
@@ -45,6 +53,20 @@ Add this line:
 
 =back
 
+=head1 CONFIGURATION
+
+You must add the desired Slack channels and webhook URLs to the
+RT %SlackWebHookUrls config value in RT_SiteConfig.pm. These values
+can be retrieved from Slack's API Incoming Webhooks configuration
+settings.
+
+The 'Notify Slack' ScripAction posts to one Slack channel. The default
+Slack channel is currently set to #general. You can update this in
+the initialdata file by changing the 'Notify Slack' ScripAction
+Argument to the desired Slack channel ( be sure to include the '#'
+when indicating the channel name ). To post to additional Slack channels,
+copy the ScripAction giving it a new Name and Argument.
+
 =head1 AUTHOR
 
 Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>

commit 1685f84705a60b2e59a91fa1072f6b8fb8f4c127
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Thu Jul 19 12:17:42 2018 -0400

    Add ticket transaction to RT when update is posted to Slack

diff --git a/lib/RT/Action/NotifySlack.pm b/lib/RT/Action/NotifySlack.pm
index 908753e..681fbc0 100644
--- a/lib/RT/Action/NotifySlack.pm
+++ b/lib/RT/Action/NotifySlack.pm
@@ -35,6 +35,9 @@ sub Commit {
     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';
+
     # Slack uses the format <www.example.com|Example Text> to insert a link into the payload's text
     my $slack_message = '<'.$rt_url.'|Ticket #'.$ticket->id.'>: '.$txn->BriefDescription;
 
@@ -53,6 +56,7 @@ sub Commit {
 
     if ($resp->is_success) {
         RT::Logger->debug('Posted to slack!');
+        $ticket->_NewTransaction( Type => 'SlackNotified' );
     } else {
         RT::Logger->debug("Failed post to slack, status is:" . $resp->status_line);
     }
diff --git a/lib/RT/Extension/NotifySlack.pm b/lib/RT/Extension/NotifySlack.pm
index 385a7a1..4455bd5 100644
--- a/lib/RT/Extension/NotifySlack.pm
+++ b/lib/RT/Extension/NotifySlack.pm
@@ -4,6 +4,14 @@ package RT::Extension::NotifySlack;
 
 our $VERSION = '0.01';
 
+use RT::Transaction;
+
+# Set message for Slack notification transactions
+$RT::Transaction::_BriefDescriptions{'SlackNotified'} = sub {
+    my $self = shift;
+    return ( 'Slack notified' );    #loc()
+};
+
 =head1 NAME
 
 RT-Extension-NotifySlack - RT ScripAction Slack integration

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list