Skip to content

feat: notify when a user account is deleted #14113

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 8 commits into from
Aug 2, 2024
Merged

feat: notify when a user account is deleted #14113

merged 8 commits into from
Aug 2, 2024

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Aug 2, 2024

Related: coder/internal#17

This PR extends api.deleteUser to notify owners and user admins when somebody deletes a new user.

@mtojek mtojek self-assigned this Aug 2, 2024
@mtojek mtojek changed the title feat: notify about deleted user account feat: notify when a user account is deleted Aug 2, 2024
@mtojek mtojek marked this pull request as ready for review August 2, 2024 11:15
@mtojek mtojek requested a review from dannykopping August 2, 2024 11:15
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, a couple things I think we need to consider before merging though.

if err != nil {
return nil, xerrors.Errorf("get owners: %w", err)
}
userAdmins, err := store.GetUsers(ctx, database.GetUsersParams{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to include org user admins here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, I will leave it as a follow-up once the org part is final. Most likely we need to adjust create account logic too.

// then
require.Len(t, notifyEnq.Sent, 2)
// notifyEnq.Sent[0] is create account event
require.Equal(t, notifications.TemplateUserAccountDeleted, notifyEnq.Sent[1].TemplateID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the owner receive an email for their own action?
We're suppressing this for users who delete their own workspaces, for example, so I wonder if we should follow the same pattern. Possible follow-up though, non-blocking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't delete your own account, so I believe there is no need to filter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i mean is: if an owner initiated an event - they should probably not receive a notification about it because it's redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that they won't receive as the API method will fail faster? see code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. you mean the owner of the action.. not the owner of the account. Interesting case, on the other hand, if somebody took over the account, notifications would work like auditing.

@mtojek mtojek requested a review from dannykopping August 2, 2024 12:03
@mtojek mtojek merged commit 6428a76 into main Aug 2, 2024
28 checks passed
@mtojek mtojek deleted the 17-account-delete branch August 2, 2024 12:56
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants