add flag to ruleset that indicates a message is forwarded, slightly modifying how junk analysis is done

part of PR #50 by bobobo1618
This commit is contained in:
Mechiel Lukkien
2023-08-09 22:31:37 +02:00
parent 9c31789c56
commit 01bcd98a42
17 changed files with 294 additions and 45 deletions

View File

@ -1039,10 +1039,6 @@ func prepareDynamicConfig(ctx context.Context, dynamicPath string, static config
for i, rs := range dest.Rulesets {
checkMailboxNormf(rs.Mailbox, "account %q, destination %q, ruleset %d", accName, addrName, i+1)
checkMailboxNormf(rs.AcceptRejectsToMailbox, "account %q, destination %q, ruleset %d, rejects mailbox", accName, addrName, i+1)
if strings.EqualFold(rs.AcceptRejectsToMailbox, "inbox") {
addErrorf("account %q, destination %q, ruleset %d: AcceptRejectsToMailbox cannot be set to Inbox", accName, addrName, i+1)
}
n := 0
@ -1088,6 +1084,14 @@ func prepareDynamicConfig(ctx context.Context, dynamicPath string, static config
addErrorf("ruleset must have at least one rule")
}
if rs.IsForward && rs.ListAllowDomain != "" {
addErrorf("ruleset cannot have both IsForward and ListAllowDomain")
}
if rs.IsForward {
if rs.SMTPMailFromRegexp == "" || rs.VerifiedDomain == "" {
addErrorf("ruleset with IsForward must have both SMTPMailFromRegexp and VerifiedDomain too")
}
}
if rs.ListAllowDomain != "" {
d, err := dns.ParseDomain(rs.ListAllowDomain)
if err != nil {
@ -1095,6 +1099,11 @@ func prepareDynamicConfig(ctx context.Context, dynamicPath string, static config
}
c.Accounts[accName].Destinations[addrName].Rulesets[i].ListAllowDNSDomain = d
}
checkMailboxNormf(rs.AcceptRejectsToMailbox, "account %q, destination %q, ruleset %d, rejects mailbox", accName, addrName, i+1)
if strings.EqualFold(rs.AcceptRejectsToMailbox, "inbox") {
addErrorf("account %q, destination %q, ruleset %d: AcceptRejectsToMailbox cannot be set to Inbox", accName, addrName, i+1)
}
}
// Catchall destination for domain.