MCPcopy Index your code
hub / github.com/writefreely/writefreely / handleAdminToggleUserStatus

Function handleAdminToggleUserStatus

admin.go:352–377  ·  view source on GitHub ↗
(app *App, u *User, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

350}
351
352func 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
379func handleAdminResetUserPass(app *App, u *User, w http.ResponseWriter, r *http.Request) error {
380 vars := mux.Vars(r)

Callers

nothing calls this directly

Calls 4

updateTimelineCacheFunction · 0.85
IsSilencedMethod · 0.80
SetUserStatusMethod · 0.80
GetUserForAuthMethod · 0.65

Tested by

no test coverage detected