[Rt-commit] r9385 - in rtir/branches/2.3-EXPERIMENTAL: t/constituency

ruz at bestpractical.com ruz at bestpractical.com
Sat Oct 20 22:34:28 EDT 2007


Author: ruz
Date: Sat Oct 20 22:34:26 2007
New Revision: 9385

Modified:
   rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
   rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t

Log:
* fix From/Reply-To addresses in autoreplies constituency specififc queues
  has different addresses.

Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	Sat Oct 20 22:34:26 2007
@@ -351,7 +351,8 @@
 }
 
 
-{
+{ # ACL checks for multiple constituencies
+
     require RT::Interface::Web::Handler;
     # flush constituency cache on each request
     wrap 'RT::Interface::Web::Handler::CleanupRequest', pre => sub {
@@ -401,7 +402,8 @@
 }
 
 
-{
+{ # Queue {Comment,Correspond}Address for multiple constituencies
+
     require RT::Ticket;
     wrap 'RT::Ticket::QueueObj', pre => sub {
         my $queue = RT::Queue->new($_[0]->CurrentUser);
@@ -468,6 +470,53 @@
 }
 
 
+{ # Set Constituency on Create
+
+    require RT::Ticket;
+    wrap 'RT::Ticket::Create', pre => sub {
+        my $ticket = $_[0];
+        my %args = (@_[1..(@_-2)]);
+
+        # get out if there is constituency value in arguments
+        my $cf = GetCustomField( '_RTIR_Constituency' );
+        return unless $cf && $cf->id;
+        return if $args{ 'CustomField-'. $cf->id };
+
+        # get out of here if it's not RTIR queue
+        my $QueueObj = RT::Queue->new( $RT::SystemUser );
+        if ( ref $args{'Queue'} eq 'RT::Queue' ) {
+            $QueueObj->Load( $args{'Queue'}->Id );
+        }
+        elsif ( $args{'Queue'} ) {
+            $QueueObj->Load( $args{'Queue'} );
+        }
+        else {
+            return;
+        }
+        return unless $QueueObj->id;
+        return unless $QueueObj->Name =~
+            /^(Incidents|Incident Reports|Investigations|Blocks)$/i; 
+        
+        # fetch value
+        my $value;
+        if ( $args{'MIMEObj'} ) {
+            my $tmp = $args{'MIMEObj'}->head->get('X-RT-Mail-Extension');
+            if ( $tmp && !grep lc $_->Name eq lc $tmp, @{ $cf->Values->ItemsArrayRef } ) {
+                $tmp = undef;
+            }
+            $value = $tmp;
+        }
+        $value ||= RT->Config->Get('_RTIR_Constituency_default');
+        return unless $value;
+
+        my @res = $ticket->Create(
+            %args,
+            'CustomField-'. $cf->id => $value,
+        );
+        $_[-1] = \@res;
+    };
+}
+
 #
 eval "require RT::IR_Vendor";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Vendor.pm});

Modified: rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t	Sat Oct 20 22:34:26 2007
@@ -70,7 +70,8 @@
     
     my $from_ok = 1;
     foreach my $mail ( @mail ) {
-        next if $mail =~ /^From:\s*.*?\Qedu-reports\@example.com/mi;
+        next if $mail =~ /^From:\s*.*?edu-reports\@example\.com/mi;
+        diag $mail;
         $from_ok = 0;
         last;
     }


More information about the Rt-commit mailing list