[Rt-commit] rt branch, 4.2/dry-run-ticket-create, created. rt-4.1.17-63-g2536348

Alex Vandiver alexmv at bestpractical.com
Fri Jul 19 13:25:02 EDT 2013


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

- Log -----------------------------------------------------------------
commit 6503da8311735bb236dc6dcce9ab6ac871ef67c4
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 c441838..5f68795 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2027,13 +2027,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;
@@ -2051,6 +2059,8 @@ sub CreateTicket {
     my %links = ProcessLinksForCreate( ARGSRef => \%ARGS );
 
     my ( $id, $Trans, $ErrMsg ) = $Ticket->Create(%create_args, %links, %cfs);
+    return $Trans if $ARGS{DryRun};
+
     unless ($id) {
         Abort($ErrMsg);
     }

commit 2536348aa9706e8fc82c14be828da294e0bf7e19
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 5f68795..67213db 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2024,7 +2024,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'}) {
@@ -2039,8 +2040,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