1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

API: Delete users asynchronously

Deleting large users might lock the tables in the hosted offering
This commit is contained in:
Frédéric Guillot 2020-07-28 20:28:02 -07:00
parent 74c95ed34b
commit 8fb71366f8
3 changed files with 101 additions and 6 deletions

View file

@ -169,10 +169,11 @@ func (h *handler) removeUser(w http.ResponseWriter, r *http.Request) {
return
}
if err := h.store.RemoveUser(user.ID); err != nil {
json.BadRequest(w, r, errors.New("Unable to remove this user from the database"))
if user.ID == request.UserID(r) {
json.BadRequest(w, r, errors.New("You cannot remove yourself"))
return
}
h.store.RemoveUserAsync(user.ID)
json.NoContent(w, r)
}