Rename Suspend status to Silence

This changes all variables and functions from using Suspend{ed} to using
Silence{d} as well as documentation, errors and logging.
This commit is contained in:
Rob Loranger 2019-11-11 15:21:45 -08:00
parent 80362000fe
commit 7e014ca659
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8
28 changed files with 128 additions and 128 deletions

View File

@ -750,7 +750,7 @@ func viewArticles(app *App, u *User, w http.ResponseWriter, r *http.Request) err
log.Error("unable to fetch collections: %v", err) log.Error("unable to fetch collections: %v", err)
} }
suspended, err := app.db.IsUserSuspended(u.ID) silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil { if err != nil {
log.Error("view articles: %v", err) log.Error("view articles: %v", err)
} }
@ -758,12 +758,12 @@ func viewArticles(app *App, u *User, w http.ResponseWriter, r *http.Request) err
*UserPage *UserPage
AnonymousPosts *[]PublicPost AnonymousPosts *[]PublicPost
Collections *[]Collection Collections *[]Collection
Suspended bool Silenced bool
}{ }{
UserPage: NewUserPage(app, r, u, u.Username+"'s Posts", f), UserPage: NewUserPage(app, r, u, u.Username+"'s Posts", f),
AnonymousPosts: p, AnonymousPosts: p,
Collections: c, Collections: c,
Suspended: suspended, Silenced: silenced,
} }
d.UserPage.SetMessaging(u) d.UserPage.SetMessaging(u)
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
@ -785,7 +785,7 @@ func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request)
uc, _ := app.db.GetUserCollectionCount(u.ID) uc, _ := app.db.GetUserCollectionCount(u.ID)
// TODO: handle any errors // TODO: handle any errors
suspended, err := app.db.IsUserSuspended(u.ID) silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil { if err != nil {
log.Error("view collections %v", err) log.Error("view collections %v", err)
return fmt.Errorf("view collections: %v", err) return fmt.Errorf("view collections: %v", err)
@ -797,13 +797,13 @@ func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request)
UsedCollections, TotalCollections int UsedCollections, TotalCollections int
NewBlogsDisabled bool NewBlogsDisabled bool
Suspended bool Silenced bool
}{ }{
UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f), UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f),
Collections: c, Collections: c,
UsedCollections: int(uc), UsedCollections: int(uc),
NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc), NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc),
Suspended: suspended, Silenced: silenced,
} }
d.UserPage.SetMessaging(u) d.UserPage.SetMessaging(u)
showUserPage(w, "collections", d) showUserPage(w, "collections", d)
@ -821,7 +821,7 @@ func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Reques
return ErrCollectionNotFound return ErrCollectionNotFound
} }
suspended, err := app.db.IsUserSuspended(u.ID) silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil { if err != nil {
log.Error("view edit collection %v", err) log.Error("view edit collection %v", err)
return fmt.Errorf("view edit collection: %v", err) return fmt.Errorf("view edit collection: %v", err)
@ -830,11 +830,11 @@ func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Reques
obj := struct { obj := struct {
*UserPage *UserPage
*Collection *Collection
Suspended bool Silenced bool
}{ }{
UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes), UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes),
Collection: c, Collection: c,
Suspended: suspended, Silenced: silenced,
} }
showUserPage(w, "collection", obj) showUserPage(w, "collection", obj)
@ -996,7 +996,7 @@ func viewStats(app *App, u *User, w http.ResponseWriter, r *http.Request) error
titleStats = c.DisplayTitle() + " " titleStats = c.DisplayTitle() + " "
} }
suspended, err := app.db.IsUserSuspended(u.ID) silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil { if err != nil {
log.Error("view stats: %v", err) log.Error("view stats: %v", err)
return err return err
@ -1007,13 +1007,13 @@ func viewStats(app *App, u *User, w http.ResponseWriter, r *http.Request) error
Collection *Collection Collection *Collection
TopPosts *[]PublicPost TopPosts *[]PublicPost
APFollowers int APFollowers int
Suspended bool Silenced bool
}{ }{
UserPage: NewUserPage(app, r, u, titleStats+"Stats", flashes), UserPage: NewUserPage(app, r, u, titleStats+"Stats", flashes),
VisitsBlog: alias, VisitsBlog: alias,
Collection: c, Collection: c,
TopPosts: topPosts, TopPosts: topPosts,
Suspended: suspended, Silenced: silenced,
} }
if app.cfg.App.Federation { if app.cfg.App.Federation {
folls, err := app.db.GetAPFollowers(c) folls, err := app.db.GetAPFollowers(c)
@ -1044,16 +1044,16 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err
obj := struct { obj := struct {
*UserPage *UserPage
Email string Email string
HasPass bool HasPass bool
IsLogOut bool IsLogOut bool
Suspended bool Silenced bool
}{ }{
UserPage: NewUserPage(app, r, u, "Account Settings", flashes), UserPage: NewUserPage(app, r, u, "Account Settings", flashes),
Email: fullUser.EmailClear(app.keys), Email: fullUser.EmailClear(app.keys),
HasPass: passIsSet, HasPass: passIsSet,
IsLogOut: r.FormValue("logout") == "1", IsLogOut: r.FormValue("logout") == "1",
Suspended: fullUser.IsSilenced(), Silenced: fullUser.IsSilenced(),
} }
showUserPage(w, "settings", obj) showUserPage(w, "settings", obj)

View File

@ -80,12 +80,12 @@ func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Re
if err != nil { if err != nil {
return err return err
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("fetch collection activities: %v", err) log.Error("fetch collection activities: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
@ -113,12 +113,12 @@ func handleFetchCollectionOutbox(app *App, w http.ResponseWriter, r *http.Reques
if err != nil { if err != nil {
return err return err
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("fetch collection outbox: %v", err) log.Error("fetch collection outbox: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
@ -174,12 +174,12 @@ func handleFetchCollectionFollowers(app *App, w http.ResponseWriter, r *http.Req
if err != nil { if err != nil {
return err return err
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("fetch collection followers: %v", err) log.Error("fetch collection followers: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
@ -228,12 +228,12 @@ func handleFetchCollectionFollowing(app *App, w http.ResponseWriter, r *http.Req
if err != nil { if err != nil {
return err return err
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("fetch collection following: %v", err) log.Error("fetch collection following: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
@ -270,12 +270,12 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
// TODO: return Reject? // TODO: return Reject?
return err return err
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("fetch collection inbox: %v", err) log.Error("fetch collection inbox: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host

View File

@ -259,7 +259,7 @@ func handleAdminToggleUserStatus(app *App, u *User, w http.ResponseWriter, r *ht
err = app.db.SetUserStatus(user.ID, UserSilenced) err = app.db.SetUserStatus(user.ID, UserSilenced)
} }
if err != nil { if err != nil {
log.Error("toggle user suspended: %v", err) log.Error("toggle user silenced: %v", err)
return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not toggle user status: %v")} return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not toggle user status: %v")}
} }
return impart.HTTPError{http.StatusFound, fmt.Sprintf("/admin/user/%s#status", username)} return impart.HTTPError{http.StatusFound, fmt.Sprintf("/admin/user/%s#status", username)}

View File

@ -71,7 +71,7 @@ type (
CurrentPage int CurrentPage int
TotalPages int TotalPages int
Format *CollectionFormat Format *CollectionFormat
Suspended bool Silenced bool
} }
SubmittedCollection struct { SubmittedCollection struct {
// Data used for updating a given collection // Data used for updating a given collection
@ -397,13 +397,13 @@ func newCollection(app *App, w http.ResponseWriter, r *http.Request) error {
} }
userID = u.ID userID = u.ID
} }
suspended, err := app.db.IsUserSuspended(userID) silenced, err := app.db.IsUserSilenced(userID)
if err != nil { if err != nil {
log.Error("new collection: %v", err) log.Error("new collection: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
if !author.IsValidUsername(app.cfg, c.Alias) { if !author.IsValidUsername(app.cfg, c.Alias) {
@ -487,7 +487,7 @@ func fetchCollection(app *App, w http.ResponseWriter, r *http.Request) error {
res.Owner = u res.Owner = u
} }
} }
// TODO: check suspended // TODO: check status for silenced
app.db.GetPostsCount(res, isCollOwner) app.db.GetPostsCount(res, isCollOwner)
// Strip non-public information // Strip non-public information
res.Collection.ForPublic() res.Collection.ForPublic()
@ -738,7 +738,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("view collection: %v", err) log.Error("view collection: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
@ -800,10 +800,10 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
log.Error("Error getting user for collection: %v", err) log.Error("Error getting user for collection: %v", err)
} }
} }
if !isOwner && suspended { if !isOwner && silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
displayPage.Suspended = isOwner && suspended displayPage.Silenced = isOwner && silenced
displayPage.Owner = owner displayPage.Owner = owner
coll.Owner = displayPage.Owner coll.Owner = displayPage.Owner
@ -909,7 +909,7 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e
if !isOwner && u.IsSilenced() { if !isOwner && u.IsSilenced() {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
displayPage.Suspended = u.IsSilenced() displayPage.Silenced = u.IsSilenced()
displayPage.Owner = owner displayPage.Owner = owner
coll.Owner = displayPage.Owner coll.Owner = displayPage.Owner
// Add more data // Add more data
@ -963,14 +963,14 @@ func existingCollection(app *App, w http.ResponseWriter, r *http.Request) error
} }
} }
suspended, err := app.db.IsUserSuspended(u.ID) silenced, err := app.db.IsUserSilenced(u.ID)
if err != nil { if err != nil {
log.Error("existing collection: %v", err) log.Error("existing collection: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
if r.Method == "DELETE" { if r.Method == "DELETE" {

View File

@ -308,18 +308,18 @@ func (db *datastore) GetUserByID(id int64) (*User, error) {
return u, nil return u, nil
} }
// IsUserSuspended returns true if the user account associated with id is // IsUserSilenced returns true if the user account associated with id is
// currently suspended. // currently silenced.
func (db *datastore) IsUserSuspended(id int64) (bool, error) { func (db *datastore) IsUserSilenced(id int64) (bool, error) {
u := &User{ID: id} u := &User{ID: id}
err := db.QueryRow("SELECT status FROM users WHERE id = ?", id).Scan(&u.Status) err := db.QueryRow("SELECT status FROM users WHERE id = ?", id).Scan(&u.Status)
switch { switch {
case err == sql.ErrNoRows: case err == sql.ErrNoRows:
return false, fmt.Errorf("is user suspended: %v", ErrUserNotFound) return false, fmt.Errorf("is user silenced: %v", ErrUserNotFound)
case err != nil: case err != nil:
log.Error("Couldn't SELECT user password: %v", err) log.Error("Couldn't SELECT user status: %v", err)
return false, fmt.Errorf("is user suspended: %v", err) return false, fmt.Errorf("is user silenced: %v", err)
} }
return u.IsSilenced(), nil return u.IsSilenced(), nil

View File

@ -48,7 +48,7 @@ var (
ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."} ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."}
ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."} ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."}
ErrUserSuspended = impart.HTTPError{http.StatusForbidden, "Account is silenced."} ErrUserSilenced = impart.HTTPError{http.StatusForbidden, "Account is silenced."}
) )
// Post operation errors // Post operation errors

View File

@ -36,12 +36,12 @@ func ViewFeed(app *App, w http.ResponseWriter, req *http.Request) error {
return nil return nil
} }
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("view feed: get user: %v", err) log.Error("view feed: get user: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrCollectionNotFound return ErrCollectionNotFound
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host

View File

@ -79,7 +79,7 @@ func handleCreateUserInvite(app *App, u *User, w http.ResponseWriter, r *http.Re
expVal := r.FormValue("expires") expVal := r.FormValue("expires")
if u.IsSilenced() { if u.IsSilenced() {
return ErrUserSuspended return ErrUserSilenced
} }
var err error var err error

18
pad.go
View File

@ -35,10 +35,10 @@ func handleViewPad(app *App, w http.ResponseWriter, r *http.Request) error {
} }
appData := &struct { appData := &struct {
page.StaticPage page.StaticPage
Post *RawPost Post *RawPost
User *User User *User
Blogs *[]Collection Blogs *[]Collection
Suspended bool Silenced bool
Editing bool // True if we're modifying an existing post Editing bool // True if we're modifying an existing post
EditCollection *Collection // Collection of the post we're editing, if any EditCollection *Collection // Collection of the post we're editing, if any
@ -53,9 +53,9 @@ func handleViewPad(app *App, w http.ResponseWriter, r *http.Request) error {
if err != nil { if err != nil {
log.Error("Unable to get user's blogs for Pad: %v", err) log.Error("Unable to get user's blogs for Pad: %v", err)
} }
appData.Suspended, err = app.db.IsUserSuspended(appData.User.ID) appData.Silenced, err = app.db.IsUserSilenced(appData.User.ID)
if err != nil { if err != nil {
log.Error("Unable to get users suspension status for Pad: %v", err) log.Error("Unable to get user status for Pad: %v", err)
} }
} }
@ -126,16 +126,16 @@ func handleViewMeta(app *App, w http.ResponseWriter, r *http.Request) error {
EditCollection *Collection // Collection of the post we're editing, if any EditCollection *Collection // Collection of the post we're editing, if any
Flashes []string Flashes []string
NeedsToken bool NeedsToken bool
Suspended bool Silenced bool
}{ }{
StaticPage: pageForReq(app, r), StaticPage: pageForReq(app, r),
Post: &RawPost{Font: "norm"}, Post: &RawPost{Font: "norm"},
User: getUserSession(app, r), User: getUserSession(app, r),
} }
var err error var err error
appData.Suspended, err = app.db.IsUserSuspended(appData.User.ID) appData.Silenced, err = app.db.IsUserSilenced(appData.User.ID)
if err != nil { if err != nil {
log.Error("view meta: get user suspended status: %v", err) log.Error("view meta: get user status: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }

View File

@ -381,7 +381,7 @@ func handleViewPost(app *App, w http.ResponseWriter, r *http.Request) error {
} }
} }
suspended, err := app.db.IsUserSuspended(ownerID.Int64) silenced, err := app.db.IsUserSilenced(ownerID.Int64)
if err != nil { if err != nil {
log.Error("view post: %v", err) log.Error("view post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
@ -434,10 +434,10 @@ func handleViewPost(app *App, w http.ResponseWriter, r *http.Request) error {
page := struct { page := struct {
*AnonymousPost *AnonymousPost
page.StaticPage page.StaticPage
Username string Username string
IsOwner bool IsOwner bool
SiteURL string SiteURL string
Suspended bool Silenced bool
}{ }{
AnonymousPost: post, AnonymousPost: post,
StaticPage: pageForReq(app, r), StaticPage: pageForReq(app, r),
@ -448,10 +448,10 @@ func handleViewPost(app *App, w http.ResponseWriter, r *http.Request) error {
page.IsOwner = ownerID.Valid && ownerID.Int64 == u.ID page.IsOwner = ownerID.Valid && ownerID.Int64 == u.ID
} }
if !page.IsOwner && suspended { if !page.IsOwner && silenced {
return ErrPostNotFound return ErrPostNotFound
} }
page.Suspended = suspended page.Silenced = silenced
err = templates["post"].ExecuteTemplate(w, "post", page) err = templates["post"].ExecuteTemplate(w, "post", page)
if err != nil { if err != nil {
log.Error("Post template execute error: %v", err) log.Error("Post template execute error: %v", err)
@ -508,13 +508,13 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error {
} else { } else {
userID = app.db.GetUserID(accessToken) userID = app.db.GetUserID(accessToken)
} }
suspended, err := app.db.IsUserSuspended(userID) silenced, err := app.db.IsUserSilenced(userID)
if err != nil { if err != nil {
log.Error("new post: %v", err) log.Error("new post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
if userID == -1 { if userID == -1 {
@ -682,13 +682,13 @@ func existingPost(app *App, w http.ResponseWriter, r *http.Request) error {
} }
} }
suspended, err := app.db.IsUserSuspended(userID) silenced, err := app.db.IsUserSilenced(userID)
if err != nil { if err != nil {
log.Error("existing post: %v", err) log.Error("existing post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
// Modify post struct // Modify post struct
@ -885,13 +885,13 @@ func addPost(app *App, w http.ResponseWriter, r *http.Request) error {
ownerID = u.ID ownerID = u.ID
} }
suspended, err := app.db.IsUserSuspended(ownerID) silenced, err := app.db.IsUserSilenced(ownerID)
if err != nil { if err != nil {
log.Error("add post: %v", err) log.Error("add post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
// Parse claimed posts in format: // Parse claimed posts in format:
@ -988,13 +988,13 @@ func pinPost(app *App, w http.ResponseWriter, r *http.Request) error {
userID = u.ID userID = u.ID
} }
suspended, err := app.db.IsUserSuspended(userID) silenced, err := app.db.IsUserSilenced(userID)
if err != nil { if err != nil {
log.Error("pin post: %v", err) log.Error("pin post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrUserSuspended return ErrUserSilenced
} }
// Parse request // Parse request
@ -1062,13 +1062,13 @@ func fetchPost(app *App, w http.ResponseWriter, r *http.Request) error {
if err != nil { if err != nil {
return err return err
} }
suspended, err := app.db.IsUserSuspended(ownerID) silenced, err := app.db.IsUserSilenced(ownerID)
if err != nil { if err != nil {
log.Error("fetch post: %v", err) log.Error("fetch post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
} }
if suspended { if silenced {
return ErrPostNotFound return ErrPostNotFound
} }
@ -1332,7 +1332,7 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error
} }
c.hostName = app.cfg.App.Host c.hostName = app.cfg.App.Host
suspended, err := app.db.IsUserSuspended(c.OwnerID) silenced, err := app.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("view collection post: %v", err) log.Error("view collection post: %v", err)
return ErrInternalGeneral return ErrInternalGeneral
@ -1394,7 +1394,7 @@ Are you sure it was ever here?`,
p.Collection = coll p.Collection = coll
p.IsTopLevel = app.cfg.App.SingleUser p.IsTopLevel = app.cfg.App.SingleUser
if !p.IsOwner && suspended { if !p.IsOwner && silenced {
return ErrPostNotFound return ErrPostNotFound
} }
// Check if post has been unpublished // Check if post has been unpublished
@ -1446,14 +1446,14 @@ Are you sure it was ever here?`,
IsFound bool IsFound bool
IsAdmin bool IsAdmin bool
CanInvite bool CanInvite bool
Suspended bool Silenced bool
}{ }{
PublicPost: p, PublicPost: p,
StaticPage: pageForReq(app, r), StaticPage: pageForReq(app, r),
IsOwner: cr.isCollOwner, IsOwner: cr.isCollOwner,
IsCustomDomain: cr.isCustomDomain, IsCustomDomain: cr.isCustomDomain,
IsFound: postFound, IsFound: postFound,
Suspended: suspended, Silenced: silenced,
} }
tp.IsAdmin = u != nil && u.IsAdmin() tp.IsAdmin = u != nil && u.IsAdmin()
tp.CanInvite = canUserInvite(app.cfg, tp.IsAdmin) tp.CanInvite = canUserInvite(app.cfg, tp.IsAdmin)

View File

@ -64,7 +64,7 @@ func initTemplate(parentDir, name string) {
filepath.Join(parentDir, templatesDir, name+".tmpl"), filepath.Join(parentDir, templatesDir, name+".tmpl"),
filepath.Join(parentDir, templatesDir, "include", "footer.tmpl"), filepath.Join(parentDir, templatesDir, "include", "footer.tmpl"),
filepath.Join(parentDir, templatesDir, "base.tmpl"), filepath.Join(parentDir, templatesDir, "base.tmpl"),
filepath.Join(parentDir, templatesDir, "user", "include", "suspended.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"),
} }
if name == "collection" || name == "collection-tags" || name == "chorus-collection" { if name == "collection" || name == "collection-tags" || name == "chorus-collection" {
// These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl" // These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl"
@ -88,7 +88,7 @@ func initPage(parentDir, path, key string) {
path, path,
filepath.Join(parentDir, templatesDir, "include", "footer.tmpl"), filepath.Join(parentDir, templatesDir, "include", "footer.tmpl"),
filepath.Join(parentDir, templatesDir, "base.tmpl"), filepath.Join(parentDir, templatesDir, "base.tmpl"),
filepath.Join(parentDir, templatesDir, "user", "include", "suspended.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"),
)) ))
} }
@ -101,7 +101,7 @@ func initUserPage(parentDir, path, key string) {
path, path,
filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl"),
filepath.Join(parentDir, templatesDir, "user", "include", "footer.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "footer.tmpl"),
filepath.Join(parentDir, templatesDir, "user", "include", "suspended.tmpl"), filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"),
)) ))
} }

View File

@ -65,8 +65,8 @@ article time.dt-published {
{{template "user-navigation" .}} {{template "user-navigation" .}}
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<article id="post-body" class="{{.Font}} h-entry">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}{{/* TODO: check format: if .Collection.Format.ShowDates*/}}<time class="dt-published" datetime="{{.Created}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time><div class="e-content">{{.HTMLContent}}</div></article> <article id="post-body" class="{{.Font}} h-entry">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}{{/* TODO: check format: if .Collection.Format.ShowDates*/}}<time class="dt-published" datetime="{{.Created}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time><div class="e-content">{{.HTMLContent}}</div></article>

View File

@ -61,8 +61,8 @@ body#collection header nav.tabs a:first-child {
<body id="collection" itemscope itemtype="http://schema.org/WebPage"> <body id="collection" itemscope itemtype="http://schema.org/WebPage">
{{template "user-navigation" .}} {{template "user-navigation" .}}
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<header> <header>
<h1 dir="{{.Direction}}" id="blog-title"><a href="/{{if .IsTopLevel}}{{else}}{{.Prefix}}{{.Alias}}/{{end}}" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1> <h1 dir="{{.Direction}}" id="blog-title"><a href="/{{if .IsTopLevel}}{{else}}{{.Prefix}}{{.Alias}}/{{end}}" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1>

View File

@ -59,8 +59,8 @@
</nav> </nav>
</header> </header>
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<article id="post-body" class="{{.Font}} h-entry {{if not .IsFound}}error-page{{end}}">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}<div class="e-content">{{.HTMLContent}}</div></article> <article id="post-body" class="{{.Font}} h-entry {{if not .IsFound}}error-page{{end}}">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}<div class="e-content">{{.HTMLContent}}</div></article>

View File

@ -53,8 +53,8 @@
</nav> </nav>
</header> </header>
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
{{if .Posts}}<section id="wrapper" itemscope itemtype="http://schema.org/Blog">{{else}}<div id="wrapper">{{end}} {{if .Posts}}<section id="wrapper" itemscope itemtype="http://schema.org/Blog">{{else}}<div id="wrapper">{{end}}
<h1>{{.Tag}}</h1> <h1>{{.Tag}}</h1>

View File

@ -62,8 +62,8 @@
</ul></nav>{{end}} </ul></nav>{{end}}
<header> <header>
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h1 dir="{{.Direction}}" id="blog-title">{{if .Posts}}{{else}}<span class="writeas-prefix"><a href="/">write.as</a></span> {{end}}<a href="/{{if .IsTopLevel}}{{else}}{{.Prefix}}{{.Alias}}/{{end}}" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1> <h1 dir="{{.Direction}}" id="blog-title">{{if .Posts}}{{else}}<span class="writeas-prefix"><a href="/">write.as</a></span> {{end}}<a href="/{{if .IsTopLevel}}{{else}}{{.Prefix}}{{.Alias}}/{{end}}" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1>
{{if .Description}}<p class="description p-note">{{.Description}}</p>{{end}} {{if .Description}}<p class="description p-note">{{.Description}}</p>{{end}}

View File

@ -269,8 +269,8 @@
<script src="/js/h.js"></script> <script src="/js/h.js"></script>
<script> <script>
function updateMeta() { function updateMeta() {
if ({{.Suspended}}) { if ({{.Silenced}}) {
alert('Your account is currently supsended, editing posts is disabled.'); alert('Your account is currently silenced, editing posts is disabled.');
return return
} }
document.getElementById('create-error').style.display = 'none'; document.getElementById('create-error').style.display = 'none';

View File

@ -131,9 +131,9 @@
{{else}}var canPublish = true;{{end}} {{else}}var canPublish = true;{{end}}
var publishing = false; var publishing = false;
var justPublished = false; var justPublished = false;
var suspended = {{.Suspended}}; var silenced = {{.Silenced}};
var publish = function(content, font) { var publish = function(content, font) {
if (suspended === true) { if (silenced === true) {
alert("Your account is silenced, so you can't publish or update posts."); alert("Your account is silenced, so you can't publish or update posts.");
return; return;
} }

View File

@ -25,8 +25,8 @@
</head> </head>
<body id="collection" itemscope itemtype="http://schema.org/WebPage"> <body id="collection" itemscope itemtype="http://schema.org/WebPage">
{{if .Suspended}} {{if .Silenced}}
{{template "user-supsended"}} {{template "user-silenced"}}
{{end}} {{end}}
<header> <header>
<h1 dir="{{.Direction}}" id="blog-title"><a href="/{{.Alias}}/" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1> <h1 dir="{{.Direction}}" id="blog-title"><a href="/{{.Alias}}/" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1>

View File

@ -49,8 +49,8 @@
</nav> </nav>
</header> </header>
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<article class="{{.Font}} h-entry">{{if .Title}}<h2 id="title" class="p-name">{{.Title}}</h2>{{end}}{{ if .IsPlainText }}<p id="post-body" class="e-content">{{.Content}}</p>{{ else }}<div id="post-body" class="e-content">{{.HTMLContent}}</div>{{ end }}</article> <article class="{{.Font}} h-entry">{{if .Title}}<h2 id="title" class="p-name">{{.Title}}</h2>{{end}}{{ if .IsPlainText }}<p id="post-body" class="e-content">{{.Content}}</p>{{ else }}<div id="post-body" class="e-content">{{.HTMLContent}}</div>{{ end }}</article>

View File

@ -7,21 +7,21 @@ table.classy th {
h3 { h3 {
font-weight: normal; font-weight: normal;
} }
td.active-suspend { td.active-silence {
display: flex; display: flex;
align-items: center; align-items: center;
} }
td.active-suspend > input[type="submit"] { td.active-silence > input[type="submit"] {
margin-left: auto; margin-left: auto;
margin-right: 5%; margin-right: 5%;
} }
@media only screen and (max-width: 500px) { @media only screen and (max-width: 500px) {
td.active-suspend { td.active-silence {
flex-wrap: wrap; flex-wrap: wrap;
} }
td.active-suspend > input[type="submit"] { td.active-silence > input[type="submit"] {
margin: auto; margin: auto;
} }
} }
@ -73,7 +73,7 @@ input.copy-text {
<form action="/admin/user/{{.User.Username}}/status" method="POST" {{if not .User.IsSilenced}}onsubmit="return confirmSilence()"{{end}}> <form action="/admin/user/{{.User.Username}}/status" method="POST" {{if not .User.IsSilenced}}onsubmit="return confirmSilence()"{{end}}>
<a id="status"/> <a id="status"/>
<th>Status</th> <th>Status</th>
<td class="active-suspend"> <td class="active-silence">
{{if .User.IsSilenced}} {{if .User.IsSilenced}}
<p>Silenced</p> <p>Silenced</p>
<input type="submit" value="Unsilence"/> <input type="submit" value="Unsilence"/>

View File

@ -6,8 +6,8 @@
{{if .Flashes}}<ul class="errors"> {{if .Flashes}}<ul class="errors">
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}} {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
</ul>{{end}} </ul>{{end}}
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h2 id="posts-header">drafts</h2> <h2 id="posts-header">drafts</h2>

View File

@ -8,8 +8,8 @@
<div class="content-container snug"> <div class="content-container snug">
<div id="overlay"></div> <div id="overlay"></div>
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h2>Customize {{.DisplayTitle}} <a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">view blog</a></h2> <h2>Customize {{.DisplayTitle}} <a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">view blog</a></h2>

View File

@ -7,8 +7,8 @@
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}} {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
</ul>{{end}} </ul>{{end}}
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h2>blogs</h2> <h2>blogs</h2>
<ul class="atoms collections"> <ul class="atoms collections">

View File

@ -1,4 +1,4 @@
{{define "user-suspended"}} {{define "user-silenced"}}
<div class="alert info"> <div class="alert info">
<p><strong>Your account has been silenced.</strong> You can still access all of your posts and blogs, but no one else can currently see them.</p> <p><strong>Your account has been silenced.</strong> You can still access all of your posts and blogs, but no one else can currently see them.</p>
</div> </div>

View File

@ -7,8 +7,8 @@ h3 { font-weight: normal; }
.section > *:not(input) { font-size: 0.86em; } .section > *:not(input) { font-size: 0.86em; }
</style> </style>
<div class="content-container snug regular"> <div class="content-container snug regular">
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h2>{{if .IsLogOut}}Before you go...{{else}}Account Settings {{if .IsAdmin}}<a href="/admin">admin settings</a>{{end}}{{end}}</h2> <h2>{{if .IsLogOut}}Before you go...{{else}}Account Settings {{if .IsAdmin}}<a href="/admin">admin settings</a>{{end}}{{end}}</h2>
{{if .Flashes}}<ul class="errors"> {{if .Flashes}}<ul class="errors">

View File

@ -17,8 +17,8 @@ td.none {
</style> </style>
<div class="content-container snug"> <div class="content-container snug">
{{if .Suspended}} {{if .Silenced}}
{{template "user-suspended"}} {{template "user-silenced"}}
{{end}} {{end}}
<h2 id="posts-header">{{if .Collection}}{{.Collection.DisplayTitle}} {{end}}Stats</h2> <h2 id="posts-header">{{if .Collection}}{{.Collection.DisplayTitle}} {{end}}Stats</h2>

View File

@ -38,12 +38,12 @@ func (wfr wfResolver) FindUser(username string, host, requestHost string, r []we
log.Error("Unable to get blog: %v", err) log.Error("Unable to get blog: %v", err)
return nil, err return nil, err
} }
suspended, err := wfr.db.IsUserSuspended(c.OwnerID) silenced, err := wfr.db.IsUserSilenced(c.OwnerID)
if err != nil { if err != nil {
log.Error("webfinger find user: check is suspended: %v", err) log.Error("webfinger find user: check is silenced: %v", err)
return nil, err return nil, err
} }
if suspended { if silenced {
return nil, wfUserNotFoundErr return nil, wfUserNotFoundErr
} }
c.hostName = wfr.cfg.App.Host c.hostName = wfr.cfg.App.Host