3 # This library of functions is used for filtering messages.
7 # processes approval decision.
11 # Subject, newsgroup, ShortDirectoryName, decision, comment
13 sub process_approval_decision {
15 my $comment = pop( @_ );
16 my $decision = pop( @_ );
17 my $ShortDirectoryName = pop( @_ );
18 my $newsgroup = pop( @_ );
19 my $Subject = pop( @_ );
21 my $address = $newsgroups_index{$newsgroup};
23 my $message = "To: $newsgroups_index{$newsgroup}\n" .
24 "Subject: $Subject\n" .
25 "Organization: http://www.algebra.com/~ichudov/stump\n";
27 $message .= "\n$decision\n";
28 $message .= "comment $comment\n" if $comment;
29 &email_message( $message, $address );
31 print STDERR "DECISION: $decision for $ShortDirectoryName sent to $address, for $newsgroup\n";
33 &rmdir_rf( &article_file_name( $ShortDirectoryName ) );
38 ###################################################################### checkAck
39 # checks the string matches one of the substrings. A name is matched
40 # against the substrings as regexps and substrings as literal substrings.
42 # Arguments: address, listname
43 sub name_is_in_list { # address, listname
44 my $listName = pop( @_ );
45 my $address = pop( @_ );
50 $address = "\L$address";
52 open( LIST, &full_config_file_name( $listName ) ) || return "";
54 while( $item = <LIST> ) {
58 next if $item =~ /^\s*$/;
60 my $quoted_item = quotemeta( $item );
62 if( eval { $address =~ /$item/i; } || $address =~ /$quoted_item/i ) {
73 ######################################################################
74 # reviews incoming message and decides: approve, reject, keep
75 # in queue for human review
77 # Arguments: Newsgroup, From, Subject, Message, Dir
79 # RealSubject is the shorter subject from original posting
80 sub review_incoming_message { # Newsgroup, From, Subject, RealSubject, Message, Dir
82 my $message = pop( @_ );
83 my $real_subject = pop( @_ );
84 my $subject = pop( @_ );
86 my $newsgroup = pop( @_ );
88 if( &name_is_in_list( $from, "bad.posters.list" ) ) {
89 &process_approval_decision( $subject, $newsgroup, $dir, "reject abuse", "" );
93 if( &name_is_in_list( $real_subject, "bad.subjects.list" ) ) {
94 &process_approval_decision( $subject, $newsgroup, $dir, "reject thread", "" );
98 if( &name_is_in_list( $message, "bad.words.list" ) ) {
99 &process_approval_decision( $subject, $newsgroup, $dir, "reject charter",
100 "Your message has been autorejected because it appears to be off topic
101 based on our filtering criteria. Like everything, filters do not
102 always work perfectly and you can always appeal this decision." );
106 my $warning_file = &article_file_name( $dir ) . "/stump-warning.txt";
109 $ignore_demo_mode = 1;
111 if( $match = &name_is_in_list( $from, "watch.posters.list" ) ) {
112 &append_to_file( $warning_file, "Warning: poster '$from' matches '$match' from the list of suspicious posters\n" );
113 print STDERR "Filing Article for review because poster '$from' matches '$match'\n";
114 return; # file message
117 if( $match = &name_is_in_list( $real_subject, "watch.subjects.list" ) ) {
118 &append_to_file( $warning_file, "Warning: subject '$real_subject' matches '$match' from the list of suspicious subjects\n" );
119 print STDERR "Filing Article for review because subject '$subject' matches '$match'\n";
120 return; # file message
123 if( $match = &name_is_in_list( $message, "watch.words.list" ) ) {
124 &append_to_file( $warning_file, "Warning: article matches '$match' from the list of suspicious words\n" );
125 print STDERR "Filing Article for review because article matches '$match'\n";
126 return; # file message
129 if( &name_is_in_list( $from, "good.posters.list" ) ) {
130 &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
134 if( &name_is_in_list( $real_subject, "good.subjects.list" ) ) {
135 &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
139 # if the message remains here, it is stored for human review.