fix recursive json marshaling

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2020-11-05 13:06:05 +01:00
parent 2dcb38acf7
commit e2b5d64618
+9 -2
View File
@@ -257,8 +257,11 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
alreadyRelated = true alreadyRelated = true
} }
} }
aref := &proto.Account{
Id: a.Id,
}
if !alreadyRelated { if !alreadyRelated {
g.Members = append(g.Members, a) g.Members = append(g.Members, aref)
} }
// check if we need to add the group to the account // check if we need to add the group to the account
@@ -269,8 +272,12 @@ func (s Service) AddMember(c context.Context, in *proto.AddMemberRequest, out *p
break break
} }
} }
// only store the reference to prevent recurision when marshaling json
gref := &proto.Group{
Id: g.Id,
}
if !alreadyRelated { if !alreadyRelated {
a.MemberOf = append(a.MemberOf, g) a.MemberOf = append(a.MemberOf, gref)
} }
if err = s.repo.WriteAccount(c, a); err != nil { if err = s.repo.WriteAccount(c, a); err != nil {