mirror of
https://github.com/Luzifer/automail.git
synced 2024-12-20 13:01:20 +00:00
Fix: Use AND matching for match-rules
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
96fa816a2d
commit
405a022a97
1 changed files with 11 additions and 3 deletions
18
handler.go
18
handler.go
|
@ -21,12 +21,20 @@ type mailHandler struct {
|
|||
}
|
||||
|
||||
func (m mailHandler) Handles(msg *enmime.Envelope) bool {
|
||||
for _, ma := range m.Match {
|
||||
if ma.Match(msg) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if len(m.Match) == 0 {
|
||||
// No matcher available: Should not match anything
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue