mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-16 09:38:49 +02:00
35 lines
785 B
Go
35 lines
785 B
Go
package grpc
|
|
|
|
import (
|
|
"context"
|
|
"google.golang.org/grpc"
|
|
pb "htwkalender/common/genproto/modules"
|
|
"htwkalender/ical/model"
|
|
"log/slog"
|
|
"time"
|
|
)
|
|
|
|
func GetEvents(modules []model.FeedModule, conn *grpc.ClientConn) (model.Events, error) {
|
|
c := pb.NewModuleServiceClient(conn)
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
defer cancel()
|
|
|
|
// List of uuids
|
|
uuids := make([]string, 0)
|
|
for _, module := range modules {
|
|
uuids = append(uuids, module.UUID)
|
|
}
|
|
|
|
r, err := c.GetEventsForModules(ctx, &pb.GetModulesRequest{Uuids: uuids})
|
|
if err != nil {
|
|
slog.Error("could not get modules: %v", "error", err)
|
|
}
|
|
|
|
events := make(model.Events, 0)
|
|
for _, event := range r.GetEvents() {
|
|
events = append(events, protoToEvent(event))
|
|
}
|
|
|
|
return events, nil
|
|
}
|