properly copy group users

This commit is contained in:
pascal
2026-01-09 13:55:17 +01:00
parent 023d85f42a
commit 29a31001bd
2 changed files with 12 additions and 1 deletions

View File

@@ -48,6 +48,14 @@ type GroupUser struct {
UserID string `gorm:"primaryKey"`
}
func (g *GroupUser) Copy() *GroupUser {
return &GroupUser{
AccountID: g.AccountID,
GroupID: g.GroupID,
UserID: g.UserID,
}
}
func (g *Group) LoadGroupPeers() {
g.Peers = make([]string, len(g.GroupPeers))
for i, peer := range g.GroupPeers {

View File

@@ -223,8 +223,11 @@ func (u *User) Copy() *User {
var groupUsers []*GroupUser
if u.Groups != nil {
groupUsers = make([]*GroupUser, len(u.Groups))
copy(groupUsers, u.Groups)
for i, groupUser := range u.Groups {
groupUsers[i] = groupUser.Copy()
}
}
var autoGroups []string
if u.AutoGroups != nil {
autoGroups = make([]string, len(u.AutoGroups))