feat: introduce feed management for individual and professor modules across frontend and backend services.

This commit is contained in:
Elmar Kresse
2025-11-22 21:20:41 +01:00
parent 34ad90d50d
commit ac6e1fe0dd
21 changed files with 1655 additions and 240 deletions

View File

@@ -18,17 +18,33 @@ package ical
import (
"encoding/json"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
"htwkalender/data-manager/model"
"htwkalender/data-manager/service/db"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
)
func CreateIndividualFeed(modules []model.FeedCollection, pb *pocketbase.PocketBase) (string, error) {
return CreateIndividualFeedWithType(modules, "", "", pb)
}
// CreateIndividualFeedWithType creates a feed with specified type and user
func CreateIndividualFeedWithType(modules []model.FeedCollection, feedType string, userId string, pb *pocketbase.PocketBase) (string, error) {
var icalFeed model.Feed
jsonModules, _ := json.Marshal(modules)
icalFeed.Modules = string(jsonModules)
// Set feed type (defaults to "student" in SaveFeed if not provided)
if feedType != "" {
icalFeed.Type = feedType
}
// Set user relation for professor feeds
if userId != "" {
icalFeed.User = userId
}
collection, dbError := pb.FindCollectionByNameOrId("feeds")
if dbError != nil {
return "", apis.NewNotFoundError("Collection could not be found", dbError)