[rt-devel] Patch to Email-Filtering

Joerg Friedrich Joerg.Dieter.Friedrich at uni-konstanz.de
Wed Feb 25 15:29:00 EST 2004


Hi, 

attached you'll find a small patch to the E-Mail Interface, which is
intended to allow Mail-Plugins to change the Queue.

Reason: Our mailsystem uses amavisd-new with spamassassin to tag mails
based on the  calculations of spamassassin. Every mail sent to the rt is
already processed by spamassassin. No additional run is needed, and we
want "possible" spam-mail to be sent to our spam-queue and not
discarded.
Yes, I know that I could use procmail and formail to do the filtering,
but IMHO it's less overhead to let the  mailparser do it. 

btw: its a quick patch, maybe it might  be safer (and more compatible)
to save the "new" queeue-id in $NewSystemQueue
and set SystemQueuee only if $NewSystemQueue is valid queue, similar to
the NewAuthState.

I'll write a filter soon, which  uses this function. (Based on the
presence of "X-Spam-Flag"-Header.)

Comments?

BTW: I'm now subscribed to this list, please not CC to my personal
address.


-- 
Jörg Friedrich
-------------- next part --------------
--- Interface/Email.pm.orig	2004-02-25 20:51:54.000000000 +0100
+++ Interface/Email.pm	2004-02-25 20:52:22.000000000 +0100
@@ -520,7 +520,7 @@
             }
         }
 
-        ( $CurrentUser, $NewAuthStat ) = $Code->(
+        ( $CurrentUser, $NewAuthStat, $SystemQueueObj) = $Code->(
             Message     => $Message,
             CurrentUser => $CurrentUser,
             AuthLevel   => $AuthStat,
--- Interface/Email/Filter/SpamAssassin.pm.orig	2004-02-25 20:52:44.000000000 +0100
+++ Interface/Email/Filter/SpamAssassin.pm	2004-02-25 20:55:30.000000000 +0100
@@ -40,9 +40,9 @@
     eval { $status->rewrite_mail() };
     if ($status->get_hits > $status->get_required_hits()*1.5) { 
         # Spammy indeed
-        return (undef, -1);
+        return (undef, -1, $incoming{'Queue'});
     }
-    return (undef, 0);
+    return (undef, 0, $incoming{'Queue'});
 }
 
 =head1 NAME
--- Interface/Email/Auth/MailFrom.pm.orig	2004-02-25 20:55:45.000000000 +0100
+++ Interface/Email/Auth/MailFrom.pm	2004-02-25 20:58:44.000000000 +0100
@@ -45,7 +45,7 @@
     }
 
     if ( $CurrentUser->Id ) {
-        return ( $CurrentUser, 1 );
+        return ( $CurrentUser, 1, $args{'Queue'} );
     }
     
 
@@ -55,14 +55,14 @@
     $unpriv->LoadSystemInternalGroup('Unprivileged');
     unless ( $unpriv->Id ) {
         $RT::Logger->crit( "Auth::MailFrom couldn't find the 'Unprivileged' internal group" );
-        return ( $args{'CurrentUser'}, -1 );
+        return ( $args{'CurrentUser'}, -1, $args{'Queue'} );
     }
 
     my $everyone = RT::Group->new($RT::SystemUser);
     $everyone->LoadSystemInternalGroup('Everyone');
     unless ( $everyone->Id ) {
         $RT::Logger->crit( "Auth::MailFrom couldn't find the 'Everyone' internal group");
-        return ( $args{'CurrentUser'}, -1 );
+        return ( $args{'CurrentUser'}, -1, $args{'Queue'} );
     }
 
     # but before we do that, we need to make sure that the created user would have the right
@@ -81,7 +81,7 @@
                                                       Right => 'CommentOnTicket'
                      )
               ) {
-                return ( $args{'CurrentUser'}, 0 );
+                return ( $args{'CurrentUser'}, 0, $args{'Queue'} );
             }
         }
         elsif ( $args{'Action'} =~ /^correspond$/i ) {
@@ -95,12 +95,12 @@
                                                        Right  => 'ReplyToTicket'
                      )
               ) {
-                return ( $args{'CurrentUser'}, 0 );
+                return ( $args{'CurrentUser'}, 0, $args{'Queue'} );
             }
 
         }
         else {
-            return ( $args{'CurrentUser'}, 0 );
+            return ( $args{'CurrentUser'}, 0, $args{'Queue'} );
         }
     }
 
@@ -113,14 +113,14 @@
                  || $unpriv->PrincipalObj->HasRight( Object => $args{'Queue'},
                                                      Right  => 'CreateTicket' )
           ) {
-            return ( $args{'CurrentUser'}, 0 );
+            return ( $args{'CurrentUser'}, 0, $args{'Queue'} );
         }
 
     }
 
     $CurrentUser = CreateUser( undef, $Address, $Name, $args{'Message'} );
 
-    return ( $CurrentUser, 1 );
+    return ( $CurrentUser, 1, $args{'Queue'} );
 }
 
 eval "require RT::Interface::Email::Auth::MailFrom_Vendor";


More information about the Rt-devel mailing list