feat:#16 added room ics api route

This commit is contained in:
Elmar Kresse
2024-10-25 00:16:02 +02:00
parent 3d41d9d6a4
commit 42172fb0a5
13 changed files with 505 additions and 6 deletions

View File

@@ -120,6 +120,27 @@ func AddFeedRoutes(app model.AppType) {
return c.JSON(http.StatusOK, "token: "+token)
})
app.Fiber.Get("/api/feed/room", func(c fiber.Ctx) error {
room := c.Query("id")
ifNoneMatch := c.Get("If-None-Match")
results, etag, err := ical.FeedRoom(app, room)
if err != nil {
slog.Error("Failed to get feed", "error", err, "room", room)
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")
return c.SendString(results)
})
app.Fiber.Head("/api/feed", func(c fiber.Ctx) error {
return c.JSON(http.StatusOK, "")
})