diff -urN ../Mail-SpamAssassin-4.0.0.orig/lib/Mail/SpamAssassin/PerMsgStatus.pm ./lib/Mail/SpamAssassin/PerMsgStatus.pm --- ../Mail-SpamAssassin-4.0.0.orig/lib/Mail/SpamAssassin/PerMsgStatus.pm 2022-12-14 08:03:21.000000000 +0200 +++ ./lib/Mail/SpamAssassin/PerMsgStatus.pm 2023-02-08 22:09:22.851701000 +0200 @@ -738,6 +738,52 @@ return ''; } +sub get_disable_learn_names { + my ($self) = @_; + my ($names); + + $self->_get_autolearn_points(); + $names = $self->{disable_learn_names}; + + if (defined $names) { + #remove trailing comma + $names =~ s/,$//; + } else { + $names = ""; + } + + return $names; +} + +sub get_mandatory_learn_names { + my ($self) = @_; + my ($names); + + $self->_get_autolearn_points(); + $names = $self->{mandatory_learn_names}; + + if (defined $names) { + #remove trailing comma + $names =~ s/,$//; + } else { + $names = ""; + } + + return $names; +} + +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) = @_; @@ -771,6 +817,8 @@ $self->{body_only_points} = 0; $self->{head_only_points} = 0; $self->{autolearn_force} = 0; + $self->{mandatory_learn} = 0; + $self->{disable_learn} = 0; foreach my $test (@{$self->{test_names_hit}}) { my $force_type = ''; @@ -779,6 +827,15 @@ if (exists $tflags->{$test}) { next if $tflags->{$test} =~ /\bnoautolearn\b/; next if $tflags->{$test} =~ /\buserconf\b/; + + if ($tflags->{$test} =~ /\bmandatory_learn\b/) { + $self->{mandatory_learn}++ ; + $self->{mandatory_learn_names}.="$test,"; + } + if ($tflags->{$test} =~ /\bdisable_learn\b/) { + $self->{disable_learn}++; + $self->{disable_learn_names}.="$test,"; + } # 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. diff -urN ../Mail-SpamAssassin-4.0.0.orig/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm ./lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm --- ../Mail-SpamAssassin-4.0.0.orig/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm 2022-12-14 08:03:20.000000000 +0200 +++ ./lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm 2023-02-08 22:09:32.243191000 +0200 @@ -166,6 +166,22 @@ my $head_only_points = $scan->get_head_only_points(); my $learned_points = $scan->get_learned_points(); + my $disable_learn = $scan->get_disable_learn(); + my $disable_learn_names = $scan->get_disable_learn_names(); + if ($disable_learn) { + dbg("learn: auto-learn? no, disable_learn"); + dbg("learn: auto-learn: disable_learn flagged because of rule(s): $disable_learn_names"); + return; + } + + my $mandatory_learn = $scan->get_mandatory_learn(); + my $mandatory_learn_names = $scan->get_mandatory_learn_names(); + if ($mandatory_learn) { + dbg("learn: auto-learn? yes, mandatory_learn"); + dbg("learn: auto-learn: mandatory_learn flagged because of rule(s): $mandatory_learn_names"); + return [1, $mandatory_learn, $mandatory_learn_names]; + } + # find out if any of the tests added an autolearn_force status my $force_autolearn = $scan->get_autolearn_force_status(); my $force_autolearn_names = $scan->get_autolearn_force_names();