diff options
author | ivan <ivan> | 2005-10-15 09:11:20 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-10-15 09:11:20 +0000 |
commit | d4d0590bef31071e8809ec046717444b95b3f30a (patch) | |
tree | ee1236da50578390d2642114f28eaed99a5efb18 /rt/lib/RT/Action | |
parent | d39d52aac8f38ea9115628039f0df5aa3ac826de (diff) |
import rt 3.4.4
Diffstat (limited to 'rt/lib/RT/Action')
-rw-r--r-- | rt/lib/RT/Action/AutoOpen.pm | 8 | ||||
-rwxr-xr-x | rt/lib/RT/Action/Autoreply.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Action/CreateTickets.pm | 29 | ||||
-rw-r--r-- | rt/lib/RT/Action/EscalatePriority.pm | 7 | ||||
-rwxr-xr-x | rt/lib/RT/Action/Generic.pm | 58 | ||||
-rwxr-xr-x | rt/lib/RT/Action/Notify.pm | 12 | ||||
-rwxr-xr-x | rt/lib/RT/Action/NotifyAsComment.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Action/RecordComment.pm | 30 | ||||
-rw-r--r-- | rt/lib/RT/Action/RecordCorrespondence.pm | 30 | ||||
-rw-r--r-- | rt/lib/RT/Action/ResolveMembers.pm | 6 | ||||
-rwxr-xr-x | rt/lib/RT/Action/SendEmail.pm | 223 | ||||
-rw-r--r-- | rt/lib/RT/Action/SetPriority.pm | 6 | ||||
-rw-r--r-- | rt/lib/RT/Action/UserDefined.pm | 6 |
13 files changed, 266 insertions, 161 deletions
diff --git a/rt/lib/RT/Action/AutoOpen.pm b/rt/lib/RT/Action/AutoOpen.pm index b28c50d3e..3423db93e 100644 --- a/rt/lib/RT/Action/AutoOpen.pm +++ b/rt/lib/RT/Action/AutoOpen.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # This Action will open the BASE if a dependent is resolved. package RT::Action::AutoOpen; @@ -74,6 +74,8 @@ sub Prepare { if ( ( $self->TicketObj->Status eq 'open' ) || ( ( $self->TicketObj->Status eq 'new' ) && $self->TransactionObj->IsInbound ) + || ( defined $self->TransactionObj->Message->First + && $self->TransactionObj->Message->First->GetHeader('RT-Control') =~ /\bno-autoopen\b/i ) ) { return undef; diff --git a/rt/lib/RT/Action/Autoreply.pm b/rt/lib/RT/Action/Autoreply.pm index 6d2894f54..c1ac5f897 100755 --- a/rt/lib/RT/Action/Autoreply.pm +++ b/rt/lib/RT/Action/Autoreply.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Action::Autoreply; require RT::Action::SendEmail; diff --git a/rt/lib/RT/Action/CreateTickets.pm b/rt/lib/RT/Action/CreateTickets.pm index 68f402e4e..b708f2ea5 100644 --- a/rt/lib/RT/Action/CreateTickets.pm +++ b/rt/lib/RT/Action/CreateTickets.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Action::CreateTickets; require RT::Action::Generic; @@ -148,8 +148,8 @@ A convoluted example push (@admins, $admin->EmailAddress); } } - Queue: Approvals - Type: Approval + Queue: ___Approvals + Type: approval AdminCc: {join ("\nAdminCc: ",@admins) } Depended-On-By: TOP Refers-To: TOP @@ -164,7 +164,7 @@ A convoluted example Subject: Manager approval Depended-On-By: TOP Refers-On: {$Tickets{"approval"}->Id} - Queue: Approvals + Queue: ___Approvals Content-Type: text/plain Content: Your approval is requred for this ticket, too. @@ -213,7 +213,7 @@ A complete list of acceptable fields for this beastie: Fields marked with an * are required. -Fields marked with a + man have multiple values, simply +Fields marked with a + may have multiple values, simply by repeating the fieldname on a new line with an additional value. Fields marked with a ! are postponed to be processed after all @@ -243,8 +243,8 @@ ok ($approvalsq->Id, "Created Approvals test queue"); my $approvals = '===Create-Ticket: approval -Queue: Approvals -Type: Approval +Queue: ___Approvals +Type: approval AdminCc: {join ("\nAdminCc: ",@admins) } Depended-On-By: {$Tickets{"TOP"}->Id} Refers-To: TOP @@ -258,7 +258,7 @@ ENDOFCONTENT ===Create-Ticket: two Subject: Manager approval. Depended-On-By: approval -Queue: Approvals +Queue: ___Approvals Content-Type: text/plain Content: Your minion approved ticket {$Tickets{"TOP"}->Id}. you ok with that? @@ -565,12 +565,14 @@ sub CreateByTemplate { # XXX: cargo cult programming that works. i'll be back. use bytes; - %T::Tickets = (); + local %T::Tickets = %T::Tickets; + local $T::TOP = $T::TOP; + local $T::ID = $T::ID; + $T::Tickets{'TOP'} = $T::TOP = $top if $top; my $ticketargs; my ( @links, @postponed ); foreach my $template_id ( @{ $self->{'create_tickets'} } ) { - $T::Tickets{'TOP'} = $T::TOP = $top if $top; $RT::Logger->debug("Workflow: processing $template_id of $T::TOP") if $T::TOP; @@ -628,7 +630,8 @@ sub UpdateByTemplate { use bytes; my @results; - %T::Tickets = (); + local %T::Tickets = %T::Tickets; + local $T::ID = $T::ID; my $ticketargs; my ( @links, @postponed ); diff --git a/rt/lib/RT/Action/EscalatePriority.pm b/rt/lib/RT/Action/EscalatePriority.pm index ace72dd1b..c54992166 100644 --- a/rt/lib/RT/Action/EscalatePriority.pm +++ b/rt/lib/RT/Action/EscalatePriority.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,8 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} + =head1 NAME RT::Action::EscalatePriority diff --git a/rt/lib/RT/Action/Generic.pm b/rt/lib/RT/Action/Generic.pm index 5e80f40d7..cf7600a63 100755 --- a/rt/lib/RT/Action/Generic.pm +++ b/rt/lib/RT/Action/Generic.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,8 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} + =head1 NAME RT::Action::Generic - a generic baseclass for RT Actions @@ -84,31 +85,31 @@ sub new { # {{{ sub _Init sub _Init { my $self = shift; - my %args = ( TransactionObj => undef, - TicketObj => undef, - ScripObj => undef, - TemplateObj => undef, - Argument => undef, - Type => undef, - CurrentUser => undef, - @_ ); - - + my %args = ( Argument => undef, + CurrentUser => undef, + ScripActionObj => undef, + ScripObj => undef, + TemplateObj => undef, + TicketObj => undef, + TransactionObj => undef, + Type => undef, + + @_ ); + $self->{'Argument'} = $args{'Argument'}; + $self->CurrentUser( $args{'CurrentUser'}); + $self->{'ScripActionObj'} = $args{'ScripActionObj'}; $self->{'ScripObj'} = $args{'ScripObj'}; + $self->{'TemplateObj'} = $args{'TemplateObj'}; $self->{'TicketObj'} = $args{'TicketObj'}; $self->{'TransactionObj'} = $args{'TransactionObj'}; - $self->{'TemplateObj'} = $args{'TemplateObj'}; $self->{'Type'} = $args{'Type'}; - $self->CurrentUser( $args{'CurrentUser'}); - Scalar::Util::weaken($self->{'ScripObj'}); - Scalar::Util::weaken($self->{'TicketObj'}); - Scalar::Util::weaken($self->{'TemplateObj'}); - Scalar::Util::weaken($self->{'TransactionObj'}); - - - + Scalar::Util::weaken($self->{'ScripActionObj'}); + Scalar::Util::weaken($self->{'ScripObj'}); + Scalar::Util::weaken($self->{'TemplateObj'}); + Scalar::Util::weaken($self->{'TicketObj'}); + Scalar::Util::weaken($self->{'TransactionObj'}); } # }}} @@ -150,6 +151,13 @@ sub ScripObj { } # }}} +# {{{ sub ScripActionObj +sub ScripActionObj { + my $self = shift; + return($self->{'ScripActionObj'}); +} +# }}} + # {{{ sub Type sub Type { my $self = shift; @@ -205,13 +213,11 @@ sub DESTROY { # We need to clean up all the references that might maybe get # oddly circular + $self->{'ScripActionObj'} = undef; + $self->{'ScripObj'} = undef; $self->{'TemplateObj'} =undef $self->{'TicketObj'} = undef; $self->{'TransactionObj'} = undef; - $self->{'ScripObj'} = undef; - - - } # }}} diff --git a/rt/lib/RT/Action/Notify.pm b/rt/lib/RT/Action/Notify.pm index 4131a8c68..0daaa5586 100755 --- a/rt/lib/RT/Action/Notify.pm +++ b/rt/lib/RT/Action/Notify.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # package RT::Action::Notify; require RT::Action::SendEmail; @@ -158,9 +158,9 @@ sub SetRecipients { @{ $self->{'Bcc'} } = @Bcc; } else { - @{ $self->{'To'} } = grep ( !/^$creator$/, @To ); - @{ $self->{'Cc'} } = grep ( !/^$creator$/, @Cc ); - @{ $self->{'Bcc'} } = grep ( !/^$creator$/, @Bcc ); + @{ $self->{'To'} } = grep ( lc $_ ne lc $creator, @To ); + @{ $self->{'Cc'} } = grep ( lc $_ ne lc $creator, @Cc ); + @{ $self->{'Bcc'} } = grep ( lc $_ ne lc $creator, @Bcc ); } @{ $self->{'PseudoTo'} } = @PseudoTo; diff --git a/rt/lib/RT/Action/NotifyAsComment.pm b/rt/lib/RT/Action/NotifyAsComment.pm index 475e3555f..f7cc87543 100755 --- a/rt/lib/RT/Action/NotifyAsComment.pm +++ b/rt/lib/RT/Action/NotifyAsComment.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Action::NotifyAsComment; require RT::Action::Notify; diff --git a/rt/lib/RT/Action/RecordComment.pm b/rt/lib/RT/Action/RecordComment.pm index b548a26eb..d9740dcd1 100644 --- a/rt/lib/RT/Action/RecordComment.pm +++ b/rt/lib/RT/Action/RecordComment.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,31 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK -# BEGIN LICENSE BLOCK -# -# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> -# -# (Except where explictly superceded by other copyright notices) -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. -# -# -# END LICENSE BLOCK -# +# END BPS TAGGED BLOCK }}} package RT::Action::RecordComment; require RT::Action::Generic; use strict; diff --git a/rt/lib/RT/Action/RecordCorrespondence.pm b/rt/lib/RT/Action/RecordCorrespondence.pm index c6770c574..62255ec53 100644 --- a/rt/lib/RT/Action/RecordCorrespondence.pm +++ b/rt/lib/RT/Action/RecordCorrespondence.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,31 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK -# BEGIN LICENSE BLOCK -# -# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> -# -# (Except where explictly superceded by other copyright notices) -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. -# -# -# END LICENSE BLOCK -# +# END BPS TAGGED BLOCK }}} package RT::Action::RecordCorrespondence; require RT::Action::Generic; use strict; diff --git a/rt/lib/RT/Action/ResolveMembers.pm b/rt/lib/RT/Action/ResolveMembers.pm index 4d751eb6d..00813181c 100644 --- a/rt/lib/RT/Action/ResolveMembers.pm +++ b/rt/lib/RT/Action/ResolveMembers.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # This Action will resolve all members of a resolved group ticket package RT::Action::ResolveMembers; diff --git a/rt/lib/RT/Action/SendEmail.pm b/rt/lib/RT/Action/SendEmail.pm index a85c169b8..3c70dc401 100755 --- a/rt/lib/RT/Action/SendEmail.pm +++ b/rt/lib/RT/Action/SendEmail.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} # Portions Copyright 2000 Tobias Brox <tobix@cpan.org> package RT::Action::SendEmail; @@ -150,6 +150,10 @@ sub Prepare { # try to convert message body from utf-8 to $RT::EmailOutputEncoding $self->SetHeader( 'Content-Type', 'text/plain; charset="utf-8"' ); + # fsck.com #5959: Since RT sends 8bit mail, we should say so. + $self->SetHeader( 'Content-Transfer-Encoding','8bit'); + + RT::I18N::SetMIMEEntityToEncoding( $MIMEObj, $RT::EmailOutputEncoding, 'mime_words_ok' ); $self->SetHeader( 'Content-Type', 'text/plain; charset="' . $RT::EmailOutputEncoding . '"' ); @@ -225,9 +229,11 @@ sub SendMessage { my $self = shift; my $MIMEObj = shift; - my $msgid = $MIMEObj->head->get('Message-Id'); + my $msgid = $MIMEObj->head->get('Message-ID'); chomp $msgid; + $self->ScripActionObj->{_Message_ID}++; + $RT::Logger->info( $msgid . " #" . $self->TicketObj->id . "/" . $self->TransactionObj->id @@ -394,12 +400,13 @@ sub RecordOutgoingMailTransaction { $type = 'EmailRecord'; } + my $msgid = $MIMEObj->head->get('Message-ID'); + chomp $msgid; - my ( $id, $msg ) = $transaction->Create( Ticket => $self->TicketObj->Id, Type => $type, - Data => $MIMEObj->head->get('Message-Id'), + Data => $msgid, MIMEObj => $MIMEObj, ActivateScrips => 0 ); @@ -427,28 +434,38 @@ sub SetRTSpecialHeaders { $self->SetHeaderAsEncoding( 'Subject', $RT::EmailOutputEncoding ) if ($RT::EmailOutputEncoding); $self->SetReturnAddress(); - - # TODO: this one is broken. What is this email really a reply to? - # If it's a reply to an incoming message, we'll need to use the - # actual message-id from the appropriate Attachment object. For - # incoming mails, we would like to preserve the In-Reply-To and/or - # References. - - $self->SetHeader( 'In-Reply-To', - "<rt-" . $self->TicketObj->id() . "\@" . $RT::rtname . ">" ); - - # TODO We should always add References headers for all message-ids - # of previous messages related to this ticket. - - $self->SetHeader( 'Message-ID', - "<rt-" - . $RT::VERSION . "-" - . $self->TicketObj->id() . "-" - . $self->TransactionObj->id() . "-" - . $self->ScripObj->Id . "." - . rand(20) . "\@" - . $RT::Organization . ">" ) - unless $self->TemplateObj->MIMEObj->head->get('Message-ID'); + $self->SetReferencesHeaders(); + + unless ($self->TemplateObj->MIMEObj->head->get('Message-ID')) { + # Get Message-ID for this txn + my $msgid = ""; + $msgid = $self->TransactionObj->Message->First->GetHeader("RT-Message-ID") + || $self->TransactionObj->Message->First->GetHeader("Message-ID") + if $self->TransactionObj->Message && $self->TransactionObj->Message->First; + + # If there is one, and we can parse it, then base our Message-ID on it + if ($msgid + and $msgid =~ s/<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>$/ + "<$1." . $self->TicketObj->id + . "-" . $self->ScripObj->id + . "-" . $self->ScripActionObj->{_Message_ID} + . "@" . $RT::Organization . ">"/eg + and $2 == $self->TicketObj->id) { + $self->SetHeader( "Message-ID" => $msgid ); + } else { + $self->SetHeader( 'Message-ID', + "<rt-" + . $RT::VERSION . "-" + . $$ . "-" + . CORE::time() . "-" + . int(rand(2000)) . '.' + . $self->TicketObj->id . "-" + . $self->ScripObj->id . "-" # Scrip + . $self->ScripActionObj->{_Message_ID} . "@" # Email sent + . $RT::Organization + . ">" ); + } + } $self->SetHeader( 'Precedence', "bulk" ) unless ( $self->TemplateObj->MIMEObj->head->get("Precedence") ); @@ -482,28 +499,67 @@ sub RemoveInappropriateRecipients { my @blacklist; + my @types = qw/To Cc Bcc/; + # Weed out any RT addresses. We really don't want to talk to ourselves! - @{ $self->{'To'} } = - RT::EmailParser::CullRTAddresses( "", @{ $self->{'To'} } ); - @{ $self->{'Cc'} } = - RT::EmailParser::CullRTAddresses( "", @{ $self->{'Cc'} } ); - @{ $self->{'Bcc'} } = - RT::EmailParser::CullRTAddresses( "", @{ $self->{'Bcc'} } ); + foreach my $type (@types) { + @{ $self->{$type} } = + RT::EmailParser::CullRTAddresses( "", @{ $self->{$type} } ); + } # If there are no recipients, don't try to send the message. # If the transaction has content and has the header RT-Squelch-Replies-To - if ( defined $self->TransactionObj->Attachments->First() ) { + if ( $self->TransactionObj->Attachments->First() ) { + if ( + $self->TransactionObj->Attachments->First->GetHeader( + 'RT-DetectedAutoGenerated') + ) + { + + # What do we want to do with this? It's probably (?) a bounce + # caused by one of the watcher addresses being broken. + # Default ("true") is to redistribute, for historical reasons. + + if ( !$RT::RedistributeAutoGeneratedMessages ) { + + # Don't send to any watchers. + @{ $self->{'To'} } = (); + @{ $self->{'Cc'} } = (); + @{ $self->{'Bcc'} } = (); + + } + elsif ( $RT::RedistributeAutoGeneratedMessages eq 'privileged' ) { + + # Only send to "privileged" watchers. + # + + foreach my $type (@types) { + + foreach my $addr ( @{ $self->{$type} } ) { + my $user = RT::User->new($RT::SystemUser); + $user->LoadByEmail($addr); + @{ $self->{$type} } = + grep ( !/^\Q$addr\E$/, @{ $self->{$type} } ) + if ( !$user->Privileged ); + + } + } + + } + + } + my $squelch = $self->TransactionObj->Attachments->First->GetHeader( 'RT-Squelch-Replies-To'); if ($squelch) { - @blacklist = split ( /,/, $squelch ); + @blacklist = split( /,/, $squelch ); } } -# Let's grab the SquelchMailTo attribue and push those entries into the @blacklist + # Let's grab the SquelchMailTo attribue and push those entries into the @blacklist my @non_recipients = $self->TicketObj->SquelchMailTo; foreach my $attribute (@non_recipients) { push @blacklist, $attribute->Content; @@ -514,10 +570,10 @@ sub RemoveInappropriateRecipients { foreach my $person_to_yank (@blacklist) { $person_to_yank =~ s/\s//g; - @{ $self->{'To'} } = grep ( !/^$person_to_yank$/, @{ $self->{'To'} } ); - @{ $self->{'Cc'} } = grep ( !/^$person_to_yank$/, @{ $self->{'Cc'} } ); - @{ $self->{'Bcc'} } = - grep ( !/^$person_to_yank$/, @{ $self->{'Bcc'} } ); + foreach my $type (@types) { + @{ $self->{$type} } = + grep ( !/^\Q$person_to_yank\E$/, @{ $self->{$type} } ); + } } } @@ -671,8 +727,93 @@ sub SetSubjectToken { # }}} +=head2 SetReferencesHeaders + +Set References and In-Reply-To headers for this message. + +=cut + +sub SetReferencesHeaders { + + my $self = shift; + my ( @in_reply_to, @references, @msgid ); + + my $attachments = $self->TransactionObj->Message; + + if ( my $top = $attachments->First() ) { + @in_reply_to = split(/\s+/m, $top->GetHeader('In-Reply-To') || ''); + @references = split(/\s+/m, $top->GetHeader('References') || '' ); + @msgid = split(/\s+/m, $top->GetHeader('Message-ID') || ''); + } + else { + return (undef); + } + + # There are two main cases -- this transaction was created with + # the RT Web UI, and hence we want to *not* append its Message-ID + # to the References and In-Reply-To. OR it came from an outside + # source, and we should treat it as per the RFC + if ( "@msgid" =~ /<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>/) { + + # Make all references which are internal be to version which we + # have sent out + for (@references, @in_reply_to) { + s/<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>$/ + "<$1." . $self->TicketObj->id . + "-" . $self->ScripObj->id . + "-" . $self->ScripActionObj->{_Message_ID} . + "@" . $RT::Organization . ">"/eg + } + + # In reply to whatever the internal message was in reply to + $self->SetHeader( 'In-Reply-To', join( " ", ( @in_reply_to ))); + + # Default the references to whatever we're in reply to + @references = @in_reply_to unless @references; + + # References are unchanged from internal + } else { + # In reply to that message + $self->SetHeader( 'In-Reply-To', join( " ", ( @msgid ))); + + # Default the references to whatever we're in reply to + @references = @in_reply_to unless @references; + + # Push that message onto the end of the references + push @references, @msgid; + } + + # Push pseudo-ref to the front + my $pseudo_ref = $self->PseudoReference; + @references = ($pseudo_ref, grep { $_ ne $pseudo_ref } @references); + + # If there are more than 10 references headers, remove all but the + # first four and the last six (Gotta keep this from growing + # forever) + splice(@references, 4, -6) if ($#references >= 10); + + # Add on the references + $self->SetHeader( 'References', join( " ", @references) ); + $self->TemplateObj->MIMEObj->head->fold_length( 'References', 80 ); + +} + # }}} +=head2 PseudoReference + +Returns a fake Message-ID: header for the ticket to allow a base level of threading + +=cut + +sub PseudoReference { + + my $self = shift; + my $pseudo_ref = '<RT-Ticket-'.$self->TicketObj->id .'@'.$RT::Organization .'>'; + return $pseudo_ref; +} + + # {{{ SetHeadingAsEncoding =head2 SetHeaderAsEncoding($field_name, $charset_encoding) diff --git a/rt/lib/RT/Action/SetPriority.pm b/rt/lib/RT/Action/SetPriority.pm index d3272a024..c129bf0a2 100644 --- a/rt/lib/RT/Action/SetPriority.pm +++ b/rt/lib/RT/Action/SetPriority.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Action::SetPriority; require RT::Action::Generic; diff --git a/rt/lib/RT/Action/UserDefined.pm b/rt/lib/RT/Action/UserDefined.pm index c298a7c7f..90653f68a 100644 --- a/rt/lib/RT/Action/UserDefined.pm +++ b/rt/lib/RT/Action/UserDefined.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Action::UserDefined; |