patch-src::MandatoryLearn-3.3.1.patch by Victor Ustugov diff -urN lib.orig/Mail/SpamAssassin/PerMsgStatus.pm lib/Mail/SpamAssassin/PerMsgStatus.pm --- lib.orig/Mail/SpamAssassin/PerMsgStatus.pm 2010-03-16 16:49:21.000000000 +0200 +++ lib/Mail/SpamAssassin/PerMsgStatus.pm 2011-02-26 17:23:13.000000000 +0200 @@ -372,6 +372,18 @@ return $self->{body_only_points}; } +sub get_mandatory_learn { + my ($self) = @_; + $self->_get_autolearn_points(); + return $self->{mandatory_learn}; +} + +sub get_disable_learn { + my ($self) = @_; + $self->_get_autolearn_points(); + return $self->{disable_learn}; +} + sub _get_autolearn_points { my ($self) = @_; @@ -402,6 +414,8 @@ $self->{learned_points} = 0; $self->{body_only_points} = 0; $self->{head_only_points} = 0; + $self->{mandatory_learn} = 0; + $self->{disable_learn} = 0; foreach my $test (@{$self->{test_names_hit}}) { # According to the documentation, noautolearn, userconf, and learn @@ -410,6 +424,9 @@ next if $tflags->{$test} =~ /\bnoautolearn\b/; next if $tflags->{$test} =~ /\buserconf\b/; + $self->{mandatory_learn} = 1 if $tflags->{$test} =~ /\bmandatory_learn\b/; + $self->{disable_learn} = 1 if $tflags->{$test} =~ /\bdisable_learn\b/; + # Keep track of the learn points for an additional autolearn check. # Use the original scoreset since it'll be 0 in sets 0 and 1. if ($tflags->{$test} =~ /\blearn\b/) { diff -urN lib.orig/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm --- lib.orig/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm 2010-03-16 16:49:21.000000000 +0200 +++ lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm 2011-02-26 21:51:36.000000000 +0200 @@ -134,6 +134,19 @@ my $head_only_points = $scan->get_head_only_points(); my $learned_points = $scan->get_learned_points(); + my $disable_learn = $scan->get_disable_learn(); + if ($disable_learn) { + dbg("learn: auto-learn? no, disable_learn"); + return; + } + + my $mandatory_learn = $scan->get_mandatory_learn(); + + if ($mandatory_learn) { + dbg("learn: auto-learn? yes, mandatory_learn"); + return $mandatory_learn; + } + dbg("learn: auto-learn? ham=$min, spam=$max, ". "body-points=".$body_only_points.", ". "head-points=".$head_only_points.", ".