From 7f96e8c38421689b2e1d39056fae4bf90a0e2bc7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 12 Nov 2019 00:40:16 +0900 Subject: [PATCH] Rename UserSuspended to UserSilenced Some of the work needed to have the backend match user-facing wording. Ref T661 --- account.go | 2 +- admin.go | 4 ++-- collections.go | 4 ++-- database.go | 2 +- invites.go | 2 +- templates/user/admin/view-user.tmpl | 2 +- users.go | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/account.go b/account.go index 25f1e0d..5fb87f0 100644 --- a/account.go +++ b/account.go @@ -1053,7 +1053,7 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err Email: fullUser.EmailClear(app.keys), HasPass: passIsSet, IsLogOut: r.FormValue("logout") == "1", - Suspended: fullUser.IsSuspended(), + Suspended: fullUser.IsSilenced(), } showUserPage(w, "settings", obj) diff --git a/admin.go b/admin.go index 2e5b8a5..e624bfb 100644 --- a/admin.go +++ b/admin.go @@ -242,10 +242,10 @@ func handleAdminToggleUserStatus(app *App, u *User, w http.ResponseWriter, r *ht log.Error("failed to get user: %v", err) return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user from username: %v", err)} } - if user.IsSuspended() { + if user.IsSilenced() { err = app.db.SetUserStatus(user.ID, UserActive) } else { - err = app.db.SetUserStatus(user.ID, UserSuspended) + err = app.db.SetUserStatus(user.ID, UserSilenced) } if err != nil { log.Error("toggle user suspended: %v", err) diff --git a/collections.go b/collections.go index fe9d89f..3e86f30 100644 --- a/collections.go +++ b/collections.go @@ -906,10 +906,10 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e log.Error("Error getting user for collection: %v", err) } } - if !isOwner && u.IsSuspended() { + if !isOwner && u.IsSilenced() { return ErrCollectionNotFound } - displayPage.Suspended = u.IsSuspended() + displayPage.Suspended = u.IsSilenced() displayPage.Owner = owner coll.Owner = displayPage.Owner // Add more data diff --git a/database.go b/database.go index 4b4f4dc..d78d888 100644 --- a/database.go +++ b/database.go @@ -322,7 +322,7 @@ func (db *datastore) IsUserSuspended(id int64) (bool, error) { return false, fmt.Errorf("is user suspended: %v", err) } - return u.IsSuspended(), nil + return u.IsSilenced(), nil } // DoesUserNeedAuth returns true if the user hasn't provided any methods for diff --git a/invites.go b/invites.go index 5f04c69..1dba7bd 100644 --- a/invites.go +++ b/invites.go @@ -78,7 +78,7 @@ func handleCreateUserInvite(app *App, u *User, w http.ResponseWriter, r *http.Re muVal := r.FormValue("uses") expVal := r.FormValue("expires") - if u.IsSuspended() { + if u.IsSilenced() { return ErrUserSuspended } diff --git a/templates/user/admin/view-user.tmpl b/templates/user/admin/view-user.tmpl index dc7b2ef..be50b12 100644 --- a/templates/user/admin/view-user.tmpl +++ b/templates/user/admin/view-user.tmpl @@ -61,7 +61,7 @@ td.active-suspend > input[type="submit"] { Status - {{if .User.IsSuspended}} + {{if .User.IsSilenced}}

Silenced

{{else}} diff --git a/users.go b/users.go index 5eb2e61..9b5c99c 100644 --- a/users.go +++ b/users.go @@ -23,7 +23,7 @@ type UserStatus int const ( UserActive = iota - UserSuspended + UserSilenced ) type ( @@ -127,6 +127,6 @@ func (u *User) IsAdmin() bool { return u.ID == 1 } -func (u *User) IsSuspended() bool { - return u.Status&UserSuspended != 0 +func (u *User) IsSilenced() bool { + return u.Status&UserSilenced != 0 }