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 {
14 my $cathow = @_>=6 ? pop(@_) : "UNKNOWN";
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 my $sanisubj= $Subject;
32 $sanisubj =~ s/.*\:\://;
34 print STDERR "DECISION: $newsgroup | $ShortDirectoryName | $decision | $cathow | $sanisubj\n";
36 &rmdir_rf( &article_file_name( $ShortDirectoryName ) );
41 ###################################################################### checkAck
42 # checks the string matches one of the substrings. A name is matched
43 # against the substrings as regexps and substrings as literal substrings.
45 # Arguments: address, listname
46 sub name_is_in_list { # address, listname
47 my $listName = pop( @_ );
48 my $address = pop( @_ );
53 $address = "\L$address";
55 open( LIST, &full_config_file_name( $listName ) ) || return "";
57 while( $item = <LIST> ) {
61 next if $item =~ /^\s*$/;
63 my $quoted_item = quotemeta( $item );
65 if( eval { $address =~ /$item/i; } || $address =~ /$quoted_item/i ) {
76 ######################################################################
77 # reviews incoming message and decides: approve, reject, keep
78 # in queue for human review
80 # Arguments: Newsgroup, From, Subject, Message, Dir
82 # RealSubject is the shorter subject from original posting
83 sub review_incoming_message { # Newsgroup, From, Subject, RealSubject, Message, Dir
85 my $message = pop( @_ );
86 my $real_subject = pop( @_ );
87 my $subject = pop( @_ );
89 my $newsgroup = pop( @_ );
91 if( &name_is_in_list( $from, "bad.posters.list" ) ) {
92 &process_approval_decision( $subject, $newsgroup, $dir, "reject abuse", "", "auto bad poster" );
96 if( &name_is_in_list( $real_subject, "bad.subjects.list" ) ) {
97 &process_approval_decision( $subject, $newsgroup, $dir, "reject thread", "", "auto bad subject" );
101 if( &name_is_in_list( $message, "bad.words.list" ) ) {
102 &process_approval_decision( $subject, $newsgroup, $dir, "reject charter",
103 "Your message has been autorejected because it appears to be off topic
104 based on our filtering criteria. Like everything, filters do not
105 always work perfectly and you can always appeal this decision.",
110 my $warning_file = &article_file_name( $dir ) . "/stump-warning.txt";
113 $ignore_demo_mode = 1;
115 if( $match = &name_is_in_list( $from, "watch.posters.list" ) ) {
116 &append_to_file( $warning_file, "Warning: poster '$from' matches '$match' from the list of suspicious posters\n" );
117 print STDERR "Filing Article for review because poster '$from' matches '$match'\n";
118 return; # file message
121 if( $match = &name_is_in_list( $real_subject, "watch.subjects.list" ) ) {
122 &append_to_file( $warning_file, "Warning: subject '$real_subject' matches '$match' from the list of suspicious subjects\n" );
123 print STDERR "Filing Article for review because subject '$subject' matches '$match'\n";
124 return; # file message
127 if( $match = &name_is_in_list( $message, "watch.words.list" ) ) {
128 &append_to_file( $warning_file, "Warning: article matches '$match' from the list of suspicious words\n" );
129 print STDERR "Filing Article for review because article matches '$match'\n";
130 return; # file message
133 if( &name_is_in_list( $from, "good.posters.list" ) ) {
134 &process_approval_decision( $subject, $newsgroup, $dir, "approve", "",
135 "auto good poster" );
139 if( &name_is_in_list( $real_subject, "good.subjects.list" ) ) {
140 &process_approval_decision( $subject, $newsgroup, $dir, "approve", "",
141 "auto good subject" );
145 # if the message remains here, it is stored for human review.