diff --git a/README.md b/README.md index 83e744c..5d97c28 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ calendars: # basic example - name: example # used as slug in URL - e.g. ical-filter-proxy:8080/calendars/example/feed?token=changeme + publish_name: "My Calendar" # the published name of the calendar - uses upstream value if this line is skipped token: "changeme" # token used to pull iCal feed - authentication is disabled when blank feed_url: "https://my-upstream-calendar.url/feed.ics" # URL for the upstream iCal feed filters: # optional - if no filters defined the upstream calendar is proxied as parsed @@ -105,6 +106,7 @@ calendars: # example: removing noise from an Office 365 calendar - name: outlook + publish_name: "My Outlook Calendar" # the published name of the calendar - uses upstream value if this line is skipped token: "changeme" feed_url: "https://outlook.office365.com/owa/calendar/.../reachcalendar.ics" filters: diff --git a/calendar.go b/calendar.go index edbf18b..2dfff0b 100644 --- a/calendar.go +++ b/calendar.go @@ -16,10 +16,11 @@ import ( // CalendarConfig definition type CalendarConfig struct { - Name string `yaml:"name"` - Token string `yaml:"token"` - FeedURL string `yaml:"feed_url"` - Filters []Filter `yaml:"filters"` + Name string `yaml:"name"` + PublishName string `yaml:"publish_name"` + Token string `yaml:"token"` + FeedURL string `yaml:"feed_url"` + Filters []Filter `yaml:"filters"` } // Downloads iCal feed from the URL and applies filtering rules @@ -44,6 +45,10 @@ func (calendarConfig CalendarConfig) fetch() ([]byte, error) { return nil, err } + if (calendarConfig.PublishName != "") { + cal.SetName(calendarConfig.PublishName) + } + // process filters if len(calendarConfig.Filters) > 0 { slog.Debug("Processing filters", "calendar", calendarConfig.Name) @@ -153,8 +158,8 @@ func (filter Filter) matchesEvent(event ics.VEvent) bool { return false // event doesn't match } } - - // Check Description filters against VEvent + + // Check Location filters against VEvent if filter.Match.Location.hasConditions() { eventLocation := event.GetProperty(ics.ComponentPropertyLocation) var eventLocationValue string @@ -191,6 +196,13 @@ func (filter Filter) transformEvent(event *ics.VEvent) { } else if filter.Transform.Description.Replace != "" { event.SetDescription(filter.Transform.Description.Replace) } + + // Location transformations + if filter.Transform.Location.Remove { + event.SetLocation("") + } else if filter.Transform.Location.Replace != "" { + event.SetLocation(filter.Transform.Location.Replace) + } } // EventMatchRules contains VEvent properties that user can match against