ScripActions for splitting AdminCC into QueueAdminCc and TicketAdminCc

From Request Tracker Wiki
Revision as of 16:37, 6 April 2016 by Admin (talk | contribs) (3 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I wanted to use the Queue AdminCcs watchers for notifications of new tickets in their queues.

By convention QueueAdminCcs are also sent email about each transaction for a ticket.  I only wanted TicketAdminCcs notified about ticket transactions.

Scrip action Notify.pm is used to send emails to the various groups of people.  I tried using the Squelch email approach but reached the same conclusion as in the email thread, that extending Notify.pm was a better solution.

Local overlay for Notify.pm

I copied lib/RT/Action/Notify.pm to local/lib/RT/Action/Notify.pm

and applied the following patch:

--- /usr/share/request-tracker4/lib/RT/Action/Notify.pm	2013-06-02 15:24:41.000000000 +0100
+++ Notify.pm	2013-08-28 10:30:50.156399864 +0100
@@ -74,6 +74,8 @@
 Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All. 
 Explicitly B notify the creator of the transaction by default
 
+Added TicketAdminCc and QueueAdminCc as recipent options.
+
 =cut
 
 sub SetRecipients {
@@ -86,6 +88,7 @@
 
     my ( @To, @PseudoTo, @Cc, @Bcc );
 
+    RT::Logger->error("Local Overlay SetRecipients Called");
 
     if ( $arg =~ /\bRequestor\b/ ) {
         push @To, $ticket->Requestors->MemberEmailAddresses;
@@ -124,6 +127,14 @@
         push ( @Bcc, $ticket->QueueObj->AdminCc->MemberEmailAddresses  );
     }
 
+    if ( $arg =~ /\bQueueAdminCc\b/ ) {
+        push ( @Bcc, $ticket->QueueObj->AdminCc->MemberEmailAddresses );
+    }
+
+    if ( $arg =~ /\bTicketAdminCc\b/ ) {
+    	push ( @Bcc, $ticket->AdminCc->MemberEmailAddresses );
+    }
+
     if ( RT->Config->Get('UseFriendlyToLine') ) {
         unless (@To) {
             push @PseudoTo,

Updating the Database

To make use of the new recipient groups from a Scrip you need to update the RT database.

I followed the instructions on Custom Scrip actions, and followed the layout in the initialData file and created a file dbUpate containing:

@ScripActions = (
        { Name => 'Notify Ticket AdminCcs',
          Description => 'Sends Mail to the Ticket AdminCcs',
          ExecModule => 'Notify',
          Argument => 'TicketAdminCc' },
        { Name => 'Notify Queue AdminCcs',
          Description => 'Sends Mail to the Queue AdminCcs',
          ExecModule => 'Notify',
          Argument => 'QueueAdminCc' }
        { Name => 'Notify Ticket AdminCcs as Comment',
          Description => 'Sends Mail to the Ticket AdminCcs as Comment',
          ExecModule => 'NotifyAsComment',
          Argument => 'TicketAdminCc' },
        { Name => 'Notify Queue AdminCcs as Comment',
          Description => 'Sends Mail to the Queue AdminCcs as Comment',
          ExecModule => 'NotifyAsComment',
          Argument => 'QueueAdminCc' }
);

I then inserted these new actions into the RT database with

rt-setup-database-4 --action insert --datafile /path/to/dbUpdate

as detailed on AddDatabaseRecords.

End Result

File:ScipActions.png
New ScripActions now available.

I updated several of the standard Scips to suit our requirements, so that only Ticket AdminCcs are notified about every ticket correspondence, and Queue AdminCcs are only notified about new tickets in their queues.