From 9aea7ac26cd3cb3e22b685257f3371dd1e2bed19 Mon Sep 17 00:00:00 2001 From: Mark Dickson Jr Date: Sat, 15 Feb 2020 22:20:14 -0500 Subject: [PATCH] Made use of new load privs flag in a few places .. in the group extension --- user/group/composite.go | 5 +++-- user/group/group.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/user/group/composite.go b/user/group/composite.go index 6b12d5c..cb9d486 100644 --- a/user/group/composite.go +++ b/user/group/composite.go @@ -85,7 +85,7 @@ func (s *Extension) LoadUserComposite(userId string) (*UserComposite, error) { for _, m := range memberships { groupIds = append(groupIds, m.GroupID) } - groups, err := s.GetGroups(groupIds) + groups, err := s.GetGroups(groupIds, true) if err != nil { return nil, err @@ -94,8 +94,9 @@ func (s *Extension) LoadUserComposite(userId string) (*UserComposite, error) { composite.Groups = groups // set the current group in the composite model we're returning + // TODO: check results of GetGroups above to avoid doing this load if u.CurrentGroupID != nil { - g, err := s.GetGroups([]string{ *u.CurrentGroupID }) + g, err := s.GetGroups([]string{ *u.CurrentGroupID }, true) if err != nil { return nil, err } diff --git a/user/group/group.go b/user/group/group.go index 554f716..9ccd17a 100644 --- a/user/group/group.go +++ b/user/group/group.go @@ -77,12 +77,12 @@ func (s *Extension) CreateGroup(name string) (nibbler.Group, error) { return group, err } -func (s *Extension) GetGroups(groupIds []string) ([]nibbler.Group, error) { +func (s *Extension) GetGroups(groupIds []string, includePrivileges bool) ([]nibbler.Group, error) { // load the groups for the set of memberships if len(groupIds) == 0 { return []nibbler.Group{}, nil } - return s.PersistenceExtension.GetGroupsById(groupIds) + return s.PersistenceExtension.GetGroupsById(groupIds, includePrivileges) }