do not use results from junk filter if we have less than 50 positive classifications to base the decision on

useful for new accounts. we don't want to start rejecting incoming messages for
having a score near 0.5 because of too little training material. we err on the
side of allowing messages in. the user will mark them as junk, training the
filter. once enough non-junk has come in, we'll start the actual filtering.

for issue #64 by x8x, and i've also seen this concern on matrix
This commit is contained in:
Mechiel Lukkien
2025-01-23 22:55:50 +01:00
parent 8fac9f862b
commit 6aa2139a54
6 changed files with 93 additions and 68 deletions

View File

@ -670,6 +670,8 @@ func TestSpam(t *testing.T) {
for i := 0; i < 3; i++ {
nm := m
tinsertmsg(t, ts.acc, "Inbox", &nm, deliverMessage)
nm = m
tinsertmsg(t, ts.acc, "mjl2", &nm, deliverMessage)
}
// Delivery from sender with bad reputation should fail.
@ -922,16 +924,22 @@ func TestDMARCSent(t *testing.T) {
// Update DNS for an SPF pass, and DMARC pass.
resolver.TXT["example.org."] = []string{"v=spf1 ip4:127.0.0.10 -all"}
// Insert spammy messages not related to the test message.
// Insert hammy & spammy messages not related to the test message.
m := store.Message{
MailFrom: "remote@test.example",
RcptToLocalpart: smtp.Localpart("mjl"),
RcptToDomain: "mox.example",
Flags: store.Flags{Seen: true, Junk: true},
Flags: store.Flags{Seen: true},
Size: int64(len(deliverMessage)),
}
for i := 0; i < 3; i++ {
// We need at least 50 ham messages for the junk filter to become significant. We
// offset it with negative messages for mediocre score.
for i := 0; i < 50; i++ {
nm := m
nm.Junk = true
tinsertmsg(t, ts.acc, "Archive", &nm, deliverMessage)
nm = m
nm.Notjunk = true
tinsertmsg(t, ts.acc, "Archive", &nm, deliverMessage)
}
tretrain(t, ts.acc)