From cace852aaa2798b1f3b5268bf453bdbac560e38b Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 25 Aug 2024 20:56:23 +0100 Subject: [PATCH] Fix variable scopes for handling description & location values --- calendar.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/calendar.go b/calendar.go index 219b39f..24feb91 100644 --- a/calendar.go +++ b/calendar.go @@ -141,11 +141,12 @@ func (filter Filter) matchesEvent(event ics.VEvent) bool { // Check Description filters against VEvent if filter.Match.Description.hasConditions() { eventDescription := event.GetProperty(ics.ComponentPropertyDescription) + var eventDescriptionValue string if eventDescription == nil { slog.Debug("Event has no Description, but continuing checking filters", "event_summary", eventSummary.Value, "filter", filter.Description) - eventDescriptionValue := "" + eventDescriptionValue = "" } else { - eventDescriptionValue := eventDescription.Value + eventDescriptionValue = eventDescription.Value } if !filter.Match.Description.matchesString(eventDescriptionValue) { @@ -157,11 +158,12 @@ func (filter Filter) matchesEvent(event ics.VEvent) bool { // Check Description filters against VEvent if filter.Match.Location.hasConditions() { eventLocation := event.GetProperty(ics.ComponentPropertyLocation) + var eventLocationValue string if eventLocation == nil { slog.Warn("Event has no Location, but continuing checking filters", "event_summary", eventSummary.Value, "filter", filter.Description) - eventLocationValue := "" + eventLocationValue = "" } else { - eventLocationValue := eventLocation.Value + eventLocationValue = eventLocation.Value } if !filter.Match.Location.matchesString(eventLocationValue) { slog.Debug("Event Location does not match filter conditions", "event_summary", eventSummary.Value, "filter", filter.Description)