Add ICS calendars (global and organizations)
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m24s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m24s
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
||||
"git.coopgo.io/coopgo-platform/agenda/storage"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
type AgendaService struct {
|
||||
@@ -21,3 +27,39 @@ func NewAgendaService(dial string) (*AgendaService, error) {
|
||||
AgendaClient: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ServicesHandler) GetAgendaEvents() ([]AgendaEvent, error) {
|
||||
resp, err := s.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
||||
Namespaces: []string{"parcoursmob_dispositifs"},
|
||||
Mindate: timestamppb.New(time.Now().Add(-24 * time.Hour)),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groups, err := s.GetGroupsMap()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error in groups request : %w", err)
|
||||
}
|
||||
|
||||
events := []AgendaEvent{}
|
||||
|
||||
for _, e := range resp.Events {
|
||||
newEvent := AgendaEvent{
|
||||
Event: e.ToStorageType(),
|
||||
}
|
||||
for _, o := range e.Owners {
|
||||
newEvent.OwnersGroups = append(newEvent.OwnersGroups, GroupsManagementGroup{Group: groups[o]})
|
||||
}
|
||||
events = append(events, newEvent)
|
||||
}
|
||||
|
||||
return events, nil
|
||||
}
|
||||
|
||||
// Enriched types
|
||||
|
||||
type AgendaEvent struct {
|
||||
OwnersGroups []GroupsManagementGroup
|
||||
storage.Event
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (s *ServicesHandler) GetGroupsMap() (groups map[string]storage.Group, err e
|
||||
return
|
||||
}
|
||||
|
||||
////////////////////////////////optimize the code//////////////////////////////////////
|
||||
// //////////////////////////////optimize the code//////////////////////////////////////
|
||||
func (s *ServicesHandler) GetGroupsMemberMap(id string) (groups map[string]any, err error) {
|
||||
groups = map[string]any{}
|
||||
|
||||
@@ -56,3 +56,9 @@ func (s *ServicesHandler) GetGroupsMemberMap(id string) (groups map[string]any,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Enriched types
|
||||
|
||||
type GroupsManagementGroup struct {
|
||||
storage.Group
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user