[Rt-commit] rt branch, 4.4/preview-batch, created. rt-4.2.3-209-g3e76591
Alex Vandiver
alexmv at bestpractical.com
Fri Jul 18 17:33:18 EDT 2014
The branch, 4.4/preview-batch has been created
at 3e76591003bb18b56d191d12e7b9644112618241 (commit)
- Log -----------------------------------------------------------------
commit 81e9950a9388a24cac596dc137b40928051448c6
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 11 15:28:54 2014 -0400
Sync the ckeditor output before updating messages
This allows the updates to the content to be respected in the data seen
by Scrips.
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index f7bc13d..6951fdd 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -214,6 +214,7 @@
<script type="text/javascript">
jQuery( function() {
var updateScrips = function() {
+ CKEDITOR.instances['UpdateContent'].updateElement();
var syncCheckboxes = function(ev) {
jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
};
@@ -227,6 +228,7 @@ jQuery( function() {
);
};
updateScrips();
+ CKEDITOR.instances['UpdateContent'].on('blur', updateScrips );
jQuery("#ticket-update-metadata :input, input[name^=UpdateCc], input[name^=UpdateBcc]").change( updateScrips );
});
</script>
commit ba4063c067b87f67aa544184632b0ff9f230e5d2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 11 15:15:23 2014 -0400
Roll back on failure to Comment, as Correspond does
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 42abbca..fabe36c 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1461,8 +1461,9 @@ sub Comment {
}
my @results = $self->_RecordNote(%args);
- if ($args{'DryRun'}) {
- $RT::Handle->Rollback();
+
+ if ( not $results[0] or $args{'DryRun'}) {
+ $RT::Handle->RollBack();
} else {
$RT::Handle->Commit();
}
commit 5c462b087cb557349057b457aa11805f504cf8e4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 11 15:20:08 2014 -0400
DryRun now wraps in a rollback, and records all transactions
DryRun was previously limited to only running correspond or comment
transactions. Change it to take a block of actions to run, which it
wraps in a transaction and rolls back at the end. By additionally
tracking all transaction objects are created on the ticket, more changes
can be simulated, and TransactionBatch changes can be found.
Note that only transactionbatch scrips directly triggered by user
changes are visible -- as scrips are not committed, TransactionBatch
changes which would be recorded because of those indirect changes will
not be visible.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index fa99323..c88bcc8 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2069,7 +2069,7 @@ sub CreateTicket {
my (@Actions);
- my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
+ my $Ticket = delete $ARGS{TicketObj} || RT::Ticket->new( $session{'CurrentUser'} );
my $Queue = RT::Queue->new( $session{'CurrentUser'} );
unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
@@ -2152,20 +2152,12 @@ sub CreateTicket {
TransSquelchMailTo => $ARGS{'TransSquelchMailTo'},
);
- 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'} || [] };
- }
- push @{$create_args{TransSquelchMailTo}}, @txn_squelch;
+ 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'} || [] };
}
+ push @{$create_args{TransSquelchMailTo}}, @txn_squelch;
if ( $ARGS{'AttachTickets'} ) {
require RT::Action::SendEmail;
@@ -2183,7 +2175,6 @@ 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);
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index fbf0fd3..f998d8a 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1630,7 +1630,6 @@ sub _NewTransaction {
Field => undef,
MIMEObj => undef,
ActivateScrips => 1,
- CommitScrips => 1,
SquelchMailTo => undef,
@_
);
@@ -1669,7 +1668,7 @@ sub _NewTransaction {
ReferenceType => $ref_type,
MIMEObj => $args{'MIMEObj'},
ActivateScrips => $args{'ActivateScrips'},
- CommitScrips => $args{'CommitScrips'},
+ DryRun => $self->{DryRun},
SquelchMailTo => $args{'SquelchMailTo'},
);
@@ -1684,7 +1683,7 @@ sub _NewTransaction {
$self->_UpdateTimeTaken( $args{'TimeTaken'}, Transaction => $trans );
}
if ( RT->Config->Get('UseTransactionBatch') and $transaction ) {
- push @{$self->{_TransactionBatch}}, $trans if $args{'CommitScrips'};
+ push @{$self->{_TransactionBatch}}, $trans;
}
RT->DatabaseHandle->Commit unless $in_txn;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index fabe36c..5ec18bb 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -237,7 +237,6 @@ sub Create {
Resolved => undef,
MIMEObj => undef,
_RecordTransaction => 1,
- DryRun => 0,
@_
);
@@ -540,7 +539,6 @@ sub Create {
Type => "Create",
TimeTaken => $args{'TimeWorked'},
MIMEObj => $args{'MIMEObj'},
- CommitScrips => !$args{'DryRun'},
SquelchMailTo => $args{'TransSquelchMailTo'},
);
@@ -560,10 +558,6 @@ sub Create {
return ( 0, 0, $self->loc( "Ticket could not be created due to an internal error"));
}
- if ( $args{'DryRun'} ) {
- $RT::Handle->Rollback();
- return ($self->id, $TransObj, $ErrStr);
- }
$RT::Handle->Commit();
return ( $self->Id, $TransObj->Id, $ErrStr );
}
@@ -1428,10 +1422,7 @@ Takes a hash with the following attributes:
If MIMEObj is undefined, Content will be used to build a MIME::Entity for this
comment.
-MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content, DryRun
-
-If DryRun is defined, this update WILL NOT BE RECORDED. Scrips will not be committed.
-They will, however, be prepared and you'll be able to access them through the TransactionObj
+MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content
Returns: Transaction id, Error Message, Transaction Object
(note the different order from Create()!)
@@ -1446,7 +1437,6 @@ sub Comment {
MIMEObj => undef,
Content => undef,
TimeTaken => 0,
- DryRun => 0,
@_ );
unless ( ( $self->CurrentUserHasRight('CommentOnTicket') )
@@ -1456,16 +1446,13 @@ sub Comment {
$args{'NoteType'} = 'Comment';
$RT::Handle->BeginTransaction();
- if ($args{'DryRun'}) {
- $args{'CommitScrips'} = 0;
- }
my @results = $self->_RecordNote(%args);
- if ( not $results[0] or $args{'DryRun'}) {
- $RT::Handle->RollBack();
+ if ( not $results[0] ) {
+ $RT::Handle->Rollback();
} else {
- $RT::Handle->Commit();
+ $RT::Handle->Commit;
}
return(@results);
@@ -1478,13 +1465,10 @@ Correspond on this ticket.
Takes a hashref with the following attributes:
-MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content, DryRun
+MIMEObj, TimeTaken, CcMessageTo, BccMessageTo, Content
if there's no MIMEObj, Content is used to build a MIME::Entity object
-If DryRun is defined, this update WILL NOT BE RECORDED. Scrips will not be committed.
-They will, however, be prepared and you'll be able to access them through the TransactionObj
-
Returns: Transaction id, Error Message, Transaction Object
(note the different order from Create()!)
@@ -1507,9 +1491,6 @@ sub Correspond {
$args{'NoteType'} = 'Correspond';
$RT::Handle->BeginTransaction();
- if ($args{'DryRun'}) {
- $args{'CommitScrips'} = 0;
- }
my @results = $self->_RecordNote(%args);
@@ -1527,11 +1508,7 @@ sub Correspond {
if grep {not $squelch{$_}} $self->Requestors->MemberEmailAddresses;
}
- if ($args{'DryRun'}) {
- $RT::Handle->Rollback();
- } else {
- $RT::Handle->Commit();
- }
+ $RT::Handle->Commit;
return (@results);
@@ -1558,7 +1535,6 @@ sub _RecordNote {
Content => undef,
NoteType => 'Correspond',
TimeTaken => 0,
- CommitScrips => 1,
SquelchMailTo => undef,
@_
);
@@ -1620,7 +1596,6 @@ sub _RecordNote {
Data => ( $args{'MIMEObj'}->head->get('subject') || 'No Subject' ),
TimeTaken => $args{'TimeTaken'},
MIMEObj => $args{'MIMEObj'},
- CommitScrips => $args{'CommitScrips'},
SquelchMailTo => $args{'SquelchMailTo'},
);
@@ -1635,89 +1610,32 @@ sub _RecordNote {
=head2 DryRun
-Builds a MIME object from the given C<UpdateSubject> and
-C<UpdateContent>, then calls L</Comment> or L</Correspond> with
-C<< DryRun => 1 >>, and returns the transaction so produced.
=cut
sub DryRun {
my $self = shift;
- my %args = @_;
- my $action;
- if (($args{'UpdateType'} || $args{Action}) =~ /^respon(d|se)$/i ) {
- $action = 'Correspond';
- } else {
- $action = 'Comment';
- }
-
- my $Message = MIME::Entity->build(
- Type => 'text/plain',
- Subject => defined $args{UpdateSubject} ? Encode::encode_utf8( $args{UpdateSubject} ) : "",
- Charset => 'UTF-8',
- Data => $args{'UpdateContent'} || "",
- );
- my ( $Transaction, $Description, $Object ) = $self->$action(
- CcMessageTo => $args{'UpdateCc'},
- BccMessageTo => $args{'UpdateBcc'},
- MIMEObj => $Message,
- TimeTaken => $args{'UpdateTimeWorked'},
- DryRun => 1,
- SquelchMailTo => $args{'SquelchMailTo'},
- );
- unless ( $Transaction ) {
- $RT::Logger->error("Couldn't fire '$action' action: $Description");
- }
+ my ($subref) = @_;
- return $Object;
-}
-
-=head2 DryRunCreate
-
-Prepares a MIME mesage with the given C<Subject>, C<Cc>, and
-C<Content>, then calls L</Create> with C<< DryRun => 1 >> and returns
-the resulting L<RT::Transaction>.
-
-=cut
+ my @transactions;
-sub DryRunCreate {
- my $self = shift;
- my %args = @_;
- my $Message = MIME::Entity->build(
- Type => 'text/plain',
- Subject => defined $args{Subject} ? Encode::encode_utf8( $args{'Subject'} ) : "",
- (defined $args{'Cc'} ?
- ( Cc => Encode::encode_utf8( $args{'Cc'} ) ) : ()),
- Charset => 'UTF-8',
- Data => $args{'Content'} || "",
- );
-
- my ( $Transaction, $Object, $Description ) = $self->Create(
- Type => $args{'Type'} || 'ticket',
- Queue => $args{'Queue'},
- Owner => $args{'Owner'},
- Requestor => $args{'Requestors'},
- Cc => $args{'Cc'},
- AdminCc => $args{'AdminCc'},
- InitialPriority => $args{'InitialPriority'},
- FinalPriority => $args{'FinalPriority'},
- TimeLeft => $args{'TimeLeft'},
- TimeEstimated => $args{'TimeEstimated'},
- TimeWorked => $args{'TimeWorked'},
- Subject => $args{'Subject'},
- Status => $args{'Status'},
- MIMEObj => $Message,
- DryRun => 1,
- );
- unless ( $Transaction ) {
- $RT::Logger->error("Couldn't fire Create action: $Description");
+ $RT::Handle->BeginTransaction();
+ {
+ # Getting nested "commit"s inside this rollback is fine
+ local %DBIx::SearchBuilder::Handle::TRANSROLLBACK;
+ local $self->{DryRun} = \@transactions;
+ eval { $subref->() };
+ warn "Error is $@" if $@;
+ $self->ApplyTransactionBatch;
}
- return $Object;
-}
+ @transactions = grep {$_} @transactions;
+ $RT::Handle->Rollback();
+ return wantarray ? @transactions : $transactions[0];
+}
sub _Links {
my $self = shift;
@@ -2591,7 +2509,8 @@ sub _ApplyTransactionBatch {
my $types = join ',', grep !$seen{$_}++, grep defined, map $_->__Value('Type'), grep defined, @{$batch};
require RT::Scrips;
- RT::Scrips->new(RT->SystemUser)->Apply(
+ my $scrips = RT::Scrips->new(RT->SystemUser);
+ $scrips->Prepare(
Stage => 'TransactionBatch',
TicketObj => $self,
TransactionObj => $batch->[0],
@@ -2605,7 +2524,16 @@ sub _ApplyTransactionBatch {
TransactionObj => $batch->[0],
Type => $types,
);
- RT::Ruleset->CommitRules($rules);
+
+ if ($self->{DryRun}) {
+ my $fake_txn = RT::Transaction->new( $self->CurrentUser );
+ $fake_txn->{scrips} = $scrips;
+ $fake_txn->{rules} = $rules;
+ push @{$self->{DryRun}}, $fake_txn;
+ } else {
+ $scrips->Commit;
+ RT::Ruleset->CommitRules($rules);
+ }
}
sub DESTROY {
@@ -3035,8 +2963,6 @@ sub Forward {
Bcc => '',
Content => '',
ContentType => 'text/plain',
- DryRun => 0,
- CommitScrips => 1,
@_
);
@@ -3067,11 +2993,6 @@ sub Forward {
)
);
- if ($args{'DryRun'}) {
- $RT::Handle->BeginTransaction();
- $args{'CommitScrips'} = 0;
- }
-
my ( $ret, $msg ) = $self->_NewTransaction(
$args{Transaction}
? (
@@ -3084,16 +3005,12 @@ sub Forward {
),
Data => join( ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc} ),
MIMEObj => $mime,
- CommitScrips => $args{'CommitScrips'},
);
unless ($ret) {
$RT::Logger->error("Failed to create transaction: $msg");
}
- if ($args{'DryRun'}) {
- $RT::Handle->Rollback();
- }
return ( $ret, $self->loc('Message recorded') );
}
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index f6329b5..be33b68 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -118,7 +118,7 @@ sub Create {
NewValue => undef,
MIMEObj => undef,
ActivateScrips => 1,
- CommitScrips => 1,
+ DryRun => undef,
ObjectType => 'RT::Ticket',
ObjectId => 0,
ReferenceType => undef,
@@ -182,6 +182,8 @@ sub Create {
return @return;
}
+ push @{$args{DryRun}}, $self if $args{DryRun};
+
$self->{'scrips'} = RT::Scrips->new(RT->SystemUser);
$RT::Logger->debug('About to prepare scrips for transaction #' .$self->Id);
@@ -206,7 +208,7 @@ sub Create {
TransactionObj => $txn,
);
- if ($args{'CommitScrips'} ) {
+ unless ($args{DryRun} ) {
$RT::Logger->debug('About to commit scrips for transaction #' .$self->Id);
$self->{'scrips'}->Commit();
RT::Ruleset->CommitRules($rules);
diff --git a/share/html/Elements/Crypt/SignEncryptWidget b/share/html/Elements/Crypt/SignEncryptWidget
index f11c0aa..165210c 100644
--- a/share/html/Elements/Crypt/SignEncryptWidget
+++ b/share/html/Elements/Crypt/SignEncryptWidget
@@ -159,11 +159,13 @@ if ( $self->{'Encrypt'} ) {
my @recipients;
if ( $Operation eq 'Update' ) {
- @recipients = $TicketObj->DryRun(%$self)->Recipients;
+ @recipients = map {$_->Recipients} $TicketObj->DryRun(
+ sub { ProcessUpdateMessage( ARGSRef => {%$self}, TicketObj => $TicketObj ) } );
}
elsif ( $Operation eq 'Create' ) {
$TicketObj = RT::Ticket->new( $session{'CurrentUser'} );
- @recipients = $TicketObj->DryRunCreate(%$self)->Recipients;
+ @recipients = map {$_->Recipients} $TicketObj->DryRun(
+ sub { CreateTicket( %$self, TicketObj => $TicketObj ); } );
}
else {
$RT::Logger->crit('Incorrect operation: '. $Operation );
diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index 8cceb89..4ec0ab3 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -60,7 +60,18 @@ else {
unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
}
-my $Object = $TicketObj->DryRun(%ARGS);
+my $Object = $TicketObj->DryRun(
+ sub {
+ local $ARGS{UpdateContent} ||= "Content";
+ ProcessUpdateMessage(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ }
+);
my %recips;
$m->abort unless $Object;
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 26d5ead..87e14a3 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -61,7 +61,18 @@ else {
unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
}
-my $Object = $TicketObj->DryRun(%ARGS);
+my $Object = $TicketObj->DryRun(
+ sub {
+ local $ARGS{UpdateContent} ||= "Content";
+ ProcessUpdateMessage(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ }
+);
$m->abort unless $Object;
my %headers = (To => {}, Cc => {}, Bcc => {});
diff --git a/share/html/Ticket/ModifyPeople.html b/share/html/Ticket/ModifyPeople.html
index ff004fc..bda19d4 100644
--- a/share/html/Ticket/ModifyPeople.html
+++ b/share/html/Ticket/ModifyPeople.html
@@ -108,7 +108,13 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup) {
}
# Use the ticket's scrips to figure out the new list of recipients.
-my @txns = grep {defined} map {$Ticket->DryRun( Action => $_ )} qw/comment respond/;
+my @txns = $Ticket->DryRun(
+ sub {
+ my $MIME = MIME::Entity->build( Type => "text/plain", Data => "" );
+ $Ticket->Comment(MIMEObj => $MIME);
+ $Ticket->Correspond(MIMEObj => $MIME);
+ }
+);
my %recips=();
for my $scrip (map {@{$_->Scrips->Prepared}} @txns) {
next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
diff --git a/t/web/gnupg-select-keys-on-create.t b/t/web/gnupg-select-keys-on-create.t
index e30b264..0e90373 100644
--- a/t/web/gnupg-select-keys-on-create.t
+++ b/t/web/gnupg-select-keys-on-create.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Test::GnuPG tests => 79, gnupg_options => { passphrase => 'rt-test' };
+use RT::Test::GnuPG tests => undef, gnupg_options => { passphrase => 'rt-test' };
use RT::Action::SendEmail;
my $queue = RT::Test->load_or_create_queue(
@@ -66,7 +66,7 @@ diag "check that things don't work if there is no key";
my @mail = RT::Test->fetch_caught_mails;
ok !@mail, 'there are no outgoing emails';
- $m->next_warning_like(qr/public key not found/) for 1 .. 4;
+ $m->next_warning_like(qr/public key not found/) for 1 .. 2;
$m->no_leftover_warnings_ok;
}
@@ -273,3 +273,5 @@ diag "check encrypting of attachments";
$m->no_warnings_ok;
}
+undef $m;
+done_testing;
commit 5e41ec13bbc34d54940ea4dcfe75bf6ae2f66bd5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 11 15:25:49 2014 -0400
Display all scrips which are triggered
Adjust the PreviewScrips and SimplifiedRecipients code to account for
multiple transactions.
diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index 4ec0ab3..ef7db09 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -60,7 +60,7 @@ else {
unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
}
-my $Object = $TicketObj->DryRun(
+my @dryrun = $TicketObj->DryRun(
sub {
local $ARGS{UpdateContent} ||= "Content";
ProcessUpdateMessage(ARGSRef => \%ARGS, TicketObj => $TicketObj );
@@ -73,7 +73,7 @@ my $Object = $TicketObj->DryRun(
}
);
my %recips;
-$m->abort unless $Object;
+$m->abort unless @dryrun;
my %squelched = ProcessTransactionSquelching( \%ARGS );
</%init>
@@ -82,13 +82,9 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
&>Uncheck boxes to disable notifications to the listed recipients <b>for this transaction only</b>; persistent squelching is managed on the <a href="[_1]">People page</a>.</&>
</p>
-% if ( $Object->Scrips ) {
-% # Sort scrips with recipients before those without
-% my @scrips = map { $_->[0] }
-% sort { ($b->[1]?1:0) <=> ($a->[1]?1:0) }
-% map { [$_, $_->ActionObj->Action->To + $_->ActionObj->Action->Cc + $_->ActionObj->Action->Bcc] }
-% grep {$_->ActionObj->Action->isa('RT::Action::SendEmail')}
-% @{$Object->Scrips->Prepared};
+% my @scrips = grep {$_->ActionObj->Action->isa('RT::Action::SendEmail')}
+% map {@{$_->Scrips->Prepared}} @dryrun;
+% if (@scrips) {
% for my $scrip (@scrips) {
<b><% $scrip->Description || loc('Scrip #[_1]',$scrip->id) %></b><br />
<&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->Template)&>[_1] [_2] with template [_3]</&>
@@ -134,8 +130,9 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
% }
% }
-% if ( $Object->Rules ) {
-% for my $rule (@{$Object->Rules}) {
+% my @rules = map {@{$_->Rules}} @dryrun;
+% if ( @rules ) {
+% for my $rule (@rules) {
% next unless $rule->{hints} && $rule->{hints}{class} eq 'SendEmail';
<b><% $rule->Describe %></b>
% my $data = $rule->{hints}{recipients};
@@ -161,4 +158,4 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
% $m->callback( CallbackName => 'AfterRecipients', TicketObj => $TicketObj );
<input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %recips %>" />
-% $m->abort();
\ No newline at end of file
+% $m->abort();
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 87e14a3..68e86cc 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -61,7 +61,7 @@ else {
unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
}
-my $Object = $TicketObj->DryRun(
+my @dryrun = $TicketObj->DryRun(
sub {
local $ARGS{UpdateContent} ||= "Content";
ProcessUpdateMessage(ARGSRef => \%ARGS, TicketObj => $TicketObj );
@@ -73,12 +73,13 @@ my $Object = $TicketObj->DryRun(
ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
}
);
-$m->abort unless $Object;
+$m->abort unless @dryrun;
my %headers = (To => {}, Cc => {}, Bcc => {});
my %no_squelch = (To => {}, Cc => {}, Bcc => {});
-if ($Object->Scrips) {
- for my $scrip (grep $_->ActionObj->Action->isa('RT::Action::SendEmail'), @{$Object->Scrips->Prepared}) {
+my @scrips = map {@{$_->Scrips->Prepared}} @dryrun;
+if (@scrips) {
+ for my $scrip (grep $_->ActionObj->Action->isa('RT::Action::SendEmail'), @scrips) {
my $action = $scrip->ActionObj->Action;
for my $type (qw(To Cc Bcc)) {
for my $addr ($action->$type()) {
@@ -91,8 +92,9 @@ if ($Object->Scrips) {
}
}
}
-if ($Object->Rules) {
- for my $rule (grep {$_->{hints} and $_->{hints}{class} eq "SendEmail"} @{$Object->Rules}) {
+my @rules = map {@{$_->Rules}} @dryrun;
+if (@rules) {
+ for my $rule (grep {$_->{hints} and $_->{hints}{class} eq "SendEmail"} @rules) {
for my $type (qw(To Cc Bcc)) {
$headers{$type}{$_} ||= @{[Email::Address->parse($_)]}[0] # Hate list context
for @{$rule->{hints}{recipients}{$type}};
commit 3e76591003bb18b56d191d12e7b9644112618241
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Jul 11 16:38:16 2014 -0400
Re-use squelching information for future updates to a ticket in same request
Prior to this, information about squelching was only associated with the
initial correspond/comment, and not later changes (such as On Owner
Change), nor TransactionBatch scrips. When updating tickets via the
web, store the squelching details on the the ticket object, and re-use
them for the lifetime of the object -- that is, the checkboxes now seen
in PreviewScrips for TransactionBatch changes are now effective.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c88bcc8..4c34b93 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2377,6 +2377,8 @@ sub _ProcessUpdateMessageRecipients {
$message_args->{SquelchMailTo} = \@txn_squelch
if @txn_squelch;
+ $args{TicketObj}->{TransSquelchMailTo} ||= $message_args->{'SquelchMailTo'};
+
unless ( $args{'ARGSRef'}->{'UpdateIgnoreAddressCheckboxes'} ) {
foreach my $key ( keys %{ $args{ARGSRef} } ) {
next unless $key =~ /^Update(Cc|Bcc)-(.*)$/;
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index f998d8a..6a9f2d4 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1669,7 +1669,7 @@ sub _NewTransaction {
MIMEObj => $args{'MIMEObj'},
ActivateScrips => $args{'ActivateScrips'},
DryRun => $self->{DryRun},
- SquelchMailTo => $args{'SquelchMailTo'},
+ SquelchMailTo => $args{'SquelchMailTo'} || $self->{TransSquelchMailTo},
);
# Rationalize the object since we may have done things to it during the caching.
-----------------------------------------------------------------------
More information about the rt-commit
mailing list