From cd97da60e96012474ae4eabd6562c3ab238d4dee Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 25 Aug 2024 22:19:55 +0100 Subject: [PATCH] Fix string match rules for empty/nil values and ensure they get processed --- calendar.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/calendar.go b/calendar.go index 24feb91..9413465 100644 --- a/calendar.go +++ b/calendar.go @@ -154,7 +154,7 @@ func (filter Filter) matchesEvent(event ics.VEvent) bool { return false // event doesn't match } } - + // Check Description filters against VEvent if filter.Match.Location.hasConditions() { eventLocation := event.GetProperty(ics.ComponentPropertyLocation) @@ -202,13 +202,9 @@ type EventMatchRules struct { Location StringMatchRule `yaml:"location"` } -type NullMatchRule struct { - Null bool `yaml:"empty"` -} - // StringMatchRule defines match rules for VEvent properties with string values type StringMatchRule struct { - NullMatchRule + Null bool `yaml:"empty"` Contains string `yaml:"contains"` Prefix string `yaml:"prefix"` Suffix string `yaml:"suffix"` @@ -217,7 +213,8 @@ type StringMatchRule struct { // Returns true if StringMatchRule has any conditions func (smr StringMatchRule) hasConditions() bool { - return smr.Contains != "" || + return smr.Null || + smr.Contains != "" || smr.Prefix != "" || smr.Suffix != "" || smr.RegexMatch != ""