equal_match.go 430 B

1234567891011121314151617181920212223
  1. package match
  2. import (
  3. "github.com/Jinnrry/pmail/dto/parsemail"
  4. "github.com/Jinnrry/pmail/utils/context"
  5. )
  6. type EqualMatch struct {
  7. Rule string
  8. Field string
  9. }
  10. func NewEqualMatch(field, rule string) *EqualMatch {
  11. return &EqualMatch{
  12. Rule: rule,
  13. Field: field,
  14. }
  15. }
  16. func (r *EqualMatch) Match(ctx *context.Context, email *parsemail.Email) bool {
  17. content := getFieldContent(r.Field, email)
  18. return content == r.Rule
  19. }