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,14 +21,22 @@ 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 {
|
||||||
cmd := exec.Command(m.Command[0], m.Command[1:]...)
|
cmd := exec.Command(m.Command[0], m.Command[1:]...)
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
Loading…
Reference in a new issue