1
0
Fork 0
mirror of https://github.com/Luzifer/automail.git synced 2024-12-30 01:31:16 +00:00

Fix: Use AND matching for match-rules

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-06-29 14:06:03 +02:00
parent 96fa816a2d
commit 405a022a97
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -21,12 +21,20 @@ type mailHandler struct {
} }
func (m mailHandler) Handles(msg *enmime.Envelope) bool { func (m mailHandler) Handles(msg *enmime.Envelope) bool {
for _, ma := range m.Match { if len(m.Match) == 0 {
if ma.Match(msg) { // No matcher available: Should not match anything
return true
}
}
return false return false
}
// Do an AND matching: As soon as one matcher fails the whole match fails
for _, ma := range m.Match {
if !ma.Match(msg) {
return false
}
}
// None has failed: It matches
return true
} }
func (m mailHandler) Process(imapClient *client.Client, msg *imap.Message, envelope *enmime.Envelope) error { func (m mailHandler) Process(imapClient *client.Client, msg *imap.Message, envelope *enmime.Envelope) error {