98 implement anonymized DTO events

This commit is contained in:
survellow
2023-12-12 23:40:43 +01:00
parent e8f29941a1
commit 9956261eab
7 changed files with 263 additions and 23 deletions

View File

@@ -1,10 +1,12 @@
package room
import (
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"htwkalender/model"
"htwkalender/service/db"
"net/http"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
)
func GetRooms(c echo.Context, app *pocketbase.PocketBase) error {
@@ -14,10 +16,19 @@ func GetRooms(c echo.Context, app *pocketbase.PocketBase) error {
func GetRoomScheduleForDay(c echo.Context, app *pocketbase.PocketBase, room string, date string) error {
events := db.GetRoomScheduleForDay(app, room, date)
return c.JSON(http.StatusOK, events)
return c.JSON(http.StatusOK, anonymizeRooms(events))
}
func GetRoomSchedule(c echo.Context, app *pocketbase.PocketBase, room string, from string, to string) error {
events := db.GetRoomSchedule(app, room, from, to)
return c.JSON(http.StatusOK, events)
return c.JSON(http.StatusOK, anonymizeRooms(events))
}
// Transform the events to anonymized events throwing away all unnecessary information
func anonymizeRooms(events []model.Event) []model.AnonymizedEventDTO {
var anonymizedEvents = []model.AnonymizedEventDTO{}
for _, event := range events {
anonymizedEvents = append(anonymizedEvents, event.AnonymizeEvent())
}
return anonymizedEvents
}