[Rt-commit] rt branch, 4.2/dry-run-ticket-create, created. rt-4.0.5-94-g0dd3ff8

Alex Vandiver alexmv at bestpractical.com
Tue Mar 20 15:16:36 EDT 2012


The branch, 4.2/dry-run-ticket-create has been created
        at  0dd3ff881d6e4194fe05cfc8cd97d95efb87894a (commit)

- Log -----------------------------------------------------------------
commit 4cbf8508dffe59ca57e272bd0b89229081dcf334
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 13:45:33 2012 -0400

    Allow DryRun => 1 to CreateTicket, which returns the txn
    
    This can hence he used to implement PreviewScrips, at the cost of losing some ticket numbers.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 39c0c8c..dc50762 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1378,13 +1378,21 @@ sub CreateTicket {
         MIMEObj         => $MIMEObj
     );
 
-    my @txn_squelch;
-    foreach my $type (qw(Requestor Cc AdminCc)) {
-        push @txn_squelch, map $_->address, Email::Address->parse( $create_args{$type} )
-            if grep $_ eq $type || $_ eq ( $type . 's' ), @{ $ARGS{'SkipNotification'} || [] };
+    if ($ARGS{'DryRun'}) {
+        $create_args{DryRun} = 1;
+        $create_args{Owner}     ||= $RT::Nobody->Id;
+        $create_args{Requestor} ||= $session{CurrentUser}->EmailAddress;
+        $create_args{Subject}   ||= '';
+        $create_args{Status}    ||= $Queue->Lifecycle->DefaultOnCreate,
+    } else {
+        my @txn_squelch;
+        foreach my $type (qw(Requestor Cc AdminCc)) {
+            push @txn_squelch, map $_->address, Email::Address->parse( $create_args{$type} )
+                if grep $_ eq $type || $_ eq ( $type . 's' ), @{ $ARGS{'SkipNotification'} || [] };
+        }
+        $create_args{TransSquelchMailTo} = \@txn_squelch
+            if @txn_squelch;
     }
-    $create_args{TransSquelchMailTo} = \@txn_squelch
-        if @txn_squelch;
 
     if ( $ARGS{'AttachTickets'} ) {
         require RT::Action::SendEmail;
@@ -1456,6 +1464,8 @@ sub CreateTicket {
     }
 
     my ( $id, $Trans, $ErrMsg ) = $Ticket->Create(%create_args);
+    return $Trans if $ARGS{DryRun};
+
     unless ($id) {
         Abort($ErrMsg);
     }

commit 0dd3ff881d6e4194fe05cfc8cd97d95efb87894a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 13:47:13 2012 -0400

    Allow explicit addresses to skip, in addition the SkipNotification sets
    
    RTIR uses the SkipNotification argument to Create (added in 7e0e0a5) to
    squelch whole classes of users at create time.  2047c32 added a
    TransSquelchTo argument to RT::Ticket->Create to implement this
    create-time squelching, but didn't allow explicit control of individual
    addresses at the level of the CreateTicket API.
    
    Add the same TransSquelchTo argument to RT::Interface::Email's
    CreateTicket, which allows an explicit additional set of addresses to
    squelch, in addition to those that SkipNotification adds.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index dc50762..ec13438 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1375,7 +1375,8 @@ sub CreateTicket {
         Status          => $ARGS{'Status'},
         Due             => $due ? $due->ISO : undef,
         Starts          => $starts ? $starts->ISO : undef,
-        MIMEObj         => $MIMEObj
+        MIMEObj         => $MIMEObj,
+        TransSquelchMailTo => $ARGS{'TransSquelchMailTo'},
     );
 
     if ($ARGS{'DryRun'}) {
@@ -1390,8 +1391,7 @@ sub CreateTicket {
             push @txn_squelch, map $_->address, Email::Address->parse( $create_args{$type} )
                 if grep $_ eq $type || $_ eq ( $type . 's' ), @{ $ARGS{'SkipNotification'} || [] };
         }
-        $create_args{TransSquelchMailTo} = \@txn_squelch
-            if @txn_squelch;
+        push @{$create_args{TransSquelchMailTo}}, @txn_squelch;
     }
 
     if ( $ARGS{'AttachTickets'} ) {

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


More information about the Rt-commit mailing list