fix:#65 reworked path param upgrade

This commit is contained in:
Elmar Kresse
2025-04-22 16:46:08 +02:00
parent 3e07451c47
commit 1e3fea26e3
4 changed files with 49 additions and 104 deletions

View File

@@ -24,24 +24,17 @@ import (
"htwkalender/data-manager/service/db"
)
func CreateIndividualFeed(requestBody []byte, app *pocketbase.PocketBase) (string, error) {
var modules []model.FeedCollection
err := json.Unmarshal(requestBody, &modules)
if err != nil {
return "", apis.NewNotFoundError("Could not parse request body", err)
}
func CreateIndividualFeed(modules []model.FeedCollection, pb *pocketbase.PocketBase) (string, error) {
var icalFeed model.Feed
jsonModules, _ := json.Marshal(modules)
icalFeed.Modules = string(jsonModules)
collection, dbError := app.FindCollectionByNameOrId("feeds")
collection, dbError := pb.FindCollectionByNameOrId("feeds")
if dbError != nil {
return "", apis.NewNotFoundError("Collection could not be found", dbError)
}
record, err := db.SaveFeed(icalFeed, collection, app)
record, err := db.SaveFeed(icalFeed, collection, pb)
if err != nil {
return "", apis.NewNotFoundError("Could not save feed", err)
}