Skip to content

feat: add notification for suspended/activated account #14367

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 20 commits into from
Aug 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
findUserAdmins
  • Loading branch information
mtojek committed Aug 22, 2024
commit a6744764becfab24cf37a3e94a086f8efdf272b6
16 changes: 2 additions & 14 deletions coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,19 +878,7 @@ func (api *API) putUserStatus(status database.UserStatus) func(rw http.ResponseW
}

// Fetch all users with user admin permissions
owners, err := api.Database.GetUsers(ctx, database.GetUsersParams{
RbacRole: []string{codersdk.RoleOwner},
})
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching owners",
Detail: err.Error(),
})
return
}
userAdmins, err := api.Database.GetUsers(ctx, database.GetUsersParams{
RbacRole: []string{codersdk.RoleUserAdmin},
})
userAdmins, err := findUserAdmins(ctx, api.Database)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching user admins",
Expand All @@ -900,7 +888,7 @@ func (api *API) putUserStatus(status database.UserStatus) func(rw http.ResponseW
}

// Send notifications to user admins and affected user
for _, u := range append(append(owners, userAdmins...), database.GetUsersRow{ID: user.ID}) {
for _, u := range append(userAdmins, database.GetUsersRow{ID: user.ID}) {
if _, err := api.NotificationsEnqueuer.Enqueue(ctx, u.ID, templateID,
map[string]string{
key: user.Username,
Expand Down
Loading