(app *App, u *User, w http.ResponseWriter, r *http.Request)
| 350 | } |
| 351 | |
| 352 | func handleAdminToggleUserStatus(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 353 | vars := mux.Vars(r) |
| 354 | username := vars["username"] |
| 355 | if username == "" { |
| 356 | return impart.HTTPError{http.StatusFound, "/admin/users"} |
| 357 | } |
| 358 | |
| 359 | user, err := app.db.GetUserForAuth(username) |
| 360 | if err != nil { |
| 361 | log.Error("failed to get user: %v", err) |
| 362 | return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user from username: %v", err)} |
| 363 | } |
| 364 | if user.IsSilenced() { |
| 365 | err = app.db.SetUserStatus(user.ID, UserActive) |
| 366 | } else { |
| 367 | err = app.db.SetUserStatus(user.ID, UserSilenced) |
| 368 | |
| 369 | // reset the cache to removed silence user posts |
| 370 | updateTimelineCache(app.timeline, true) |
| 371 | } |
| 372 | if err != nil { |
| 373 | log.Error("toggle user silenced: %v", err) |
| 374 | return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not toggle user status: %v", err)} |
| 375 | } |
| 376 | return impart.HTTPError{http.StatusFound, fmt.Sprintf("/admin/user/%s#status", username)} |
| 377 | } |
| 378 | |
| 379 | func handleAdminResetUserPass(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 380 | vars := mux.Vars(r) |
nothing calls this directly
no test coverage detected