diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index acec647..0cc15fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Bulid +name: Build on: - push diff --git a/README.md b/README.md index 92cc018..b0eddb5 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,28 @@ # ics2mattermost > **Note** > -> An ICS (calendar) parser sending todays Events and Absentees to Mattermost. +> An ICS (calendar) parser; sending todays Events and Absentees to Mattermost. -This application was created out of need for a Mattermost notification informing +This application was created out of need for a Mattermost notification, informing us of todays appointments. -We wanted to display todays absentees, Meetingslinks and Daily times. +We wanted to display todays absentees, Meetingslinks and Daily/meeting times. I use a personal access token to access our (confluence) ics calendar and parse todays appointments. One notification gets send to our channel with all of the aggregated information. +# Usage +Currently four Env Variables are necessary to run the application: +```sh +export ICS_URL= + +export MATTERMOST_URL= + +export ICS_USER= +export ICS_TOKEN= +``` +*Remember:* the ics/calendar config is done with confluence in mind + # Development Setup: ```bash @@ -24,5 +36,5 @@ Creat a new Incomig Webhook Integration and export that URL as Run tests: ```bash -go tests ./... +make test ``` diff --git a/icsparser/daily.go b/icsparser/daily.go index 5d2170a..e0db5f6 100644 --- a/icsparser/daily.go +++ b/icsparser/daily.go @@ -17,7 +17,7 @@ type DailyIngest struct { func (c *Calendar) gatherRelevantEvents() DailyIngest { - var ingest DailyIngest + var ingest DailyIngest for _, event := range c.Events { travelers, err := event.GetPersonsByCategory("travel") @@ -54,19 +54,31 @@ func (c *Calendar) PrepareDailyIngest() (map[string]string, error) { logger.Info(fmt.Sprintf("amount of meetings: %d", len(ingest.EventsToday))) loc := time.Local - var formattedEvents string + var formattedEvents, travellers, absentees string for _, e := range ingest.EventsToday { formattedEvents = formattedEvents + ":calendar: " + e.Start.In(loc).Format("15:04") + " - " + e.End.In(loc).Format("15:04 MST") + " :fire: [" + e.Summary + "](" + e.Location + ")\n" } + if len(ingest.AbsentPersons) == 0 { + absentees = "*no one*" + } else { + absentees = strings.Join(ingest.AbsentPersons, ", ") + } + + if len(ingest.TravellingPersons) == 0 { + travellers = "*no one*" + } else { + travellers = strings.Join(ingest.TravellingPersons, ", ") + } + dailyMessage := map[string]string{ "name": "Foobar", "text": "#### Welcome to VRP's daily ingest\n" + formattedEvents + - ":airplane: " + strings.Join(ingest.TravellingPersons, ", ") + "\n" + - ":palm_tree: " + strings.Join(ingest.AbsentPersons, ", "), + ":airplane: " + travellers + "\n" + + ":palm_tree: " + absentees, } // logger.Info(