Skip to content

feat: add avatar urls to groups #4525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 17, 2022
Prev Previous commit
Next Next commit
fix some dumb shit
  • Loading branch information
sreya committed Oct 13, 2022
commit 223182f7bc7050a255f931d35ce32c5d4fe577d1
24 changes: 12 additions & 12 deletions enterprise/coderd/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
return
}

// If the name matches the existing group name pretend we aren't
// updating the name at all.
if req.Name == group.Name {
req.Name = ""
}

users := make([]string, 0, len(req.AddUsers)+len(req.RemoveUsers))
users = append(users, req.AddUsers...)
users = append(users, req.RemoveUsers...)
Expand Down Expand Up @@ -110,22 +116,16 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
return
}
}
if req.Name != "" {
existingGroup, err := api.Database.GetGroupByOrgAndName(ctx, database.GetGroupByOrgAndNameParams{
if req.Name != "" && req.Name != group.Name {
_, err := api.Database.GetGroupByOrgAndName(ctx, database.GetGroupByOrgAndNameParams{
OrganizationID: group.OrganizationID,
Name: req.Name,
})
if err == nil {
// We may have just queried ourself. This should really
// go in the tx.
if existingGroup.ID != group.ID {
httpapi.Write(ctx, rw, http.StatusConflict, codersdk.Response{
Message: fmt.Sprintf("A group with name %q already exists.", req.Name),
})
return
}
// If we queried ourself then we don't want to update the name.
req.Name = ""
httpapi.Write(ctx, rw, http.StatusConflict, codersdk.Response{
Message: fmt.Sprintf("A group with name %q already exists.", req.Name),
})
return
}
}

Expand Down