Merge branch 'refs/heads/development' into 49-add-htwkarte-linkout-at-ics-event-info

# Conflicts:
#	services/ical/main.go
#	services/ical/service/ical/ical.go
#	services/ical/service/routes.go
This commit is contained in:
Elmar Kresse
2024-10-17 10:54:29 +02:00
26 changed files with 883 additions and 40 deletions

View File

@@ -34,13 +34,12 @@ func AddFeedRoutes(app model.AppType) {
app.Fiber.Get("/api/feed", func(c fiber.Ctx) error {
token := c.Query("token")
ifNoneMatch := c.Get("If-None-Match")
// get request userAgent and check if it is Thunderbird
userAgent := c.Get("User-Agent")
slog.Info("User-Agent", "userAgent", userAgent)
results, err := ical.Feed(app, token, userAgent)
results, eTag, err := ical.Feed(app, token, userAgent)
if errors.Is(err, ical.FeedDeletedError) {
return c.SendStatus(fiber.StatusGone)
@@ -50,10 +49,16 @@ func AddFeedRoutes(app model.AppType) {
slog.Error("Failed to get feed", "error", err, "token", token)
return c.SendStatus(fiber.StatusNotFound)
}
if ifNoneMatch == eTag && ifNoneMatch != "" {
return c.SendStatus(fiber.StatusNotModified)
}
c.Response().Header.Set("Content-type", "text/calendar")
c.Response().Header.Set("charset", "utf-8")
c.Response().Header.Set("Content-Disposition", "inline")
c.Response().Header.Set("filename", "calendar.ics")
c.Response().Header.Set("ETag", eTag)
return c.SendString(results)
})