mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-09 13:17:48 +02:00
21 add reminder booleans, map uuid to module
This commit is contained in:
@@ -3,14 +3,15 @@ package ical
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/jordic/goics"
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"htwkalender/model"
|
||||
"htwkalender/service/db"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/jordic/goics"
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
)
|
||||
|
||||
const expirationTime = 5 * time.Minute
|
||||
@@ -23,8 +24,13 @@ func Feed(c echo.Context, app *pocketbase.PocketBase, token string) error {
|
||||
return c.JSON(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
var modules []model.FeedCollection
|
||||
_ = json.Unmarshal([]byte(feed.Modules), &modules)
|
||||
modules := make(map[string]model.FeedCollection)
|
||||
var modulesArray []model.FeedCollection
|
||||
_ = json.Unmarshal([]byte(feed.Modules), &modulesArray)
|
||||
|
||||
for _, module := range modulesArray {
|
||||
modules[module.UUID] = module
|
||||
}
|
||||
|
||||
newFeed, err := createFeedForToken(app, modules)
|
||||
if err != nil {
|
||||
@@ -41,7 +47,7 @@ func Feed(c echo.Context, app *pocketbase.PocketBase, token string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createFeedForToken(app *pocketbase.PocketBase, modules []model.FeedCollection) (*model.FeedModel, error) {
|
||||
func createFeedForToken(app *pocketbase.PocketBase, modules map[string]model.FeedCollection) (*model.FeedModel, error) {
|
||||
res := db.GetPlanForModules(app, modules)
|
||||
b := bytes.Buffer{}
|
||||
goics.NewICalEncode(&b).Encode(IcalModel{Events: res, Mapping: modules})
|
||||
|
Reference in New Issue
Block a user