chiark / gitweb /
webstump: use "reject blocklist" for the hardcoded blocklist-related rejection reason
[modbot-mtm.git] / webstump / scripts / filter.lib.pl
index b98b22d731bde5d8039484dff7f4426fb0792d5b..3a41cb5656d19a1a5e9cfa3f8736e9bb6db7cb41 100644 (file)
 # Subject, newsgroup, ShortDirectoryName, decision, comment
 
 sub process_approval_decision {
-
+  my $cathow = @_>=6 ? pop(@_) : "UNKNOWN";
   my $comment = pop( @_ );
   my $decision = pop( @_ );
   my $ShortDirectoryName = pop( @_ );
   my $newsgroup = pop( @_ );
   my $Subject = pop( @_ );
+  my $now = time;
 
   my $address = $newsgroups_index{$newsgroup};
 
@@ -28,7 +29,10 @@ sub process_approval_decision {
   $message .= "comment $comment\n" if $comment;
   &email_message( $message, $address );
 
-print STDERR "DECISION: $decision for $ShortDirectoryName sent to $address, for $newsgroup\n";
+  my $sanisubj= $Subject;
+  $sanisubj =~ s/.*\:\://;
+
+print STDERR "DECISION: $newsgroup | $ShortDirectoryName | $decision | $cathow | $now | $sanisubj\n";
 
   &rmdir_rf( &article_file_name( $ShortDirectoryName ) );
 
@@ -40,6 +44,7 @@ print STDERR "DECISION: $decision for $ShortDirectoryName sent to $address, for
 # against the substrings as regexps and substrings as literal substrings.
 #
 # Arguments: address, listname
+
 sub name_is_in_list { # address, listname
   my $listName = pop( @_ );
   my $address = pop( @_ );
@@ -47,20 +52,23 @@ sub name_is_in_list { # address, listname
   my $item = "";
   my $Result = "";
 
-  $address = "\L$address";
-
   open( LIST, &full_config_file_name( $listName ) ) || return "";
 
   while( $item = <LIST> ) {
 
-    chop $item;
-
-    next if $item =~ /^\s*$/;
+    chomp $item;
 
-    my $quoted_item = quotemeta( $item );
+    next unless $item =~ /\S/;
+    next if $item =~ /^\s*\#/;
 
-    if( eval { $address =~ /$item/i; } || $address =~ /$quoted_item/i ) {
-      $Result = $item;
+    if ($listName eq 'good.posters.list') {
+       if( lc $address eq lc $item ) {
+           $Result = $item;
+       }
+    } else {
+       if( eval { $address =~ /$item/i; } ) {
+           $Result = $item;
+       }
     }
   }
 
@@ -69,7 +77,6 @@ sub name_is_in_list { # address, listname
   return $Result;
 }
 
-
 ######################################################################
 # reviews incoming message and decides: approve, reject, keep
 # in queue for human review
@@ -86,12 +93,12 @@ sub review_incoming_message { # Newsgroup, From, Subject, RealSubject, Message,
   my $newsgroup = pop( @_ );
 
   if( &name_is_in_list( $from, "bad.posters.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "reject abuse", "" );
+    &process_approval_decision( $subject, $newsgroup, $dir, "reject blocklist", "", "auto bad poster" );
     return;
   }
 
   if( &name_is_in_list( $real_subject, "bad.subjects.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "reject thread", "" );
+    &process_approval_decision( $subject, $newsgroup, $dir, "reject thread", "", "auto bad subject" );
     return;
   }
 
@@ -99,7 +106,8 @@ sub review_incoming_message { # Newsgroup, From, Subject, RealSubject, Message,
     &process_approval_decision( $subject, $newsgroup, $dir, "reject charter", 
     "Your message has been autorejected because it appears to be off topic
     based on our filtering criteria. Like everything, filters do not
-    always work perfectly and you can always appeal this decision." );
+    always work perfectly and you can always appeal this decision.",
+                                "auto bad word" );
     return;
   }
 
@@ -127,12 +135,14 @@ print STDERR "Filing Article for review because article matches '$match'\n";
   }
 
   if( &name_is_in_list( $from, "good.posters.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
+    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "",
+                                "auto good poster" );
     return;
   }
 
   if( &name_is_in_list( $real_subject, "good.subjects.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
+    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "",
+                                "auto good subject" );
     return;
   }