mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 20:29:54 -06:00
graph: Make createGroupModelFromCS3() function public
This is useful outside the identity module so make it available
This commit is contained in:
committed by
Ralf Haferkamp
parent
f008d6624a
commit
f2599dfa76
@@ -5,7 +5,8 @@ import (
|
||||
"net/url"
|
||||
|
||||
"github.com/CiscoM31/godata"
|
||||
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
cs3group "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
|
||||
cs3user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode"
|
||||
)
|
||||
@@ -103,9 +104,10 @@ type EducationBackend interface {
|
||||
RemoveTeacherFromEducationClass(ctx context.Context, classID string, teacherID string) error
|
||||
}
|
||||
|
||||
func CreateUserModelFromCS3(u *cs3.User) *libregraph.User {
|
||||
// CreateUserModelFromCS3 converts a cs3 User object into a libregraph.User
|
||||
func CreateUserModelFromCS3(u *cs3user.User) *libregraph.User {
|
||||
if u.Id == nil {
|
||||
u.Id = &cs3.UserId{}
|
||||
u.Id = &cs3user.UserId{}
|
||||
}
|
||||
return &libregraph.User{
|
||||
DisplayName: &u.DisplayName,
|
||||
@@ -114,3 +116,14 @@ func CreateUserModelFromCS3(u *cs3.User) *libregraph.User {
|
||||
Id: &u.Id.OpaqueId,
|
||||
}
|
||||
}
|
||||
|
||||
// CreateGroupModelFromCS3 converts a cs3 Group object into a libregraph.Group
|
||||
func CreateGroupModelFromCS3(g *cs3group.Group) *libregraph.Group {
|
||||
if g.Id == nil {
|
||||
g.Id = &cs3group.GroupId{}
|
||||
}
|
||||
return &libregraph.Group{
|
||||
Id: &g.Id.OpaqueId,
|
||||
DisplayName: &g.GroupName,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func (i *CS3) GetGroups(ctx context.Context, queryParam url.Values) ([]*libregra
|
||||
groups := make([]*libregraph.Group, 0, len(res.Groups))
|
||||
|
||||
for _, group := range res.Groups {
|
||||
groups = append(groups, createGroupModelFromCS3(group))
|
||||
groups = append(groups, CreateGroupModelFromCS3(group))
|
||||
}
|
||||
|
||||
return groups, nil
|
||||
@@ -185,7 +185,7 @@ func (i *CS3) GetGroup(ctx context.Context, groupID string, queryParam url.Value
|
||||
return nil, errorcode.New(errorcode.GeneralException, res.Status.Message)
|
||||
}
|
||||
|
||||
return createGroupModelFromCS3(res.Group), nil
|
||||
return CreateGroupModelFromCS3(res.Group), nil
|
||||
}
|
||||
|
||||
// DeleteGroup implements the Backend Interface. It's currently not supported for the CS3 backend
|
||||
@@ -212,14 +212,3 @@ func (i *CS3) AddMembersToGroup(ctx context.Context, groupID string, memberID []
|
||||
func (i *CS3) RemoveMemberFromGroup(ctx context.Context, groupID string, memberID string) error {
|
||||
return errorcode.New(errorcode.NotSupported, "not implemented")
|
||||
}
|
||||
|
||||
func createGroupModelFromCS3(g *cs3group.Group) *libregraph.Group {
|
||||
if g.Id == nil {
|
||||
g.Id = &cs3group.GroupId{}
|
||||
}
|
||||
return &libregraph.Group{
|
||||
Id: &g.Id.OpaqueId,
|
||||
DisplayName: &g.GroupName,
|
||||
// TODO when to fetch and expand memberof, usernames or ids?
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user