Add nested posts UI cutover.
CI / test (pull_request) Successful in 8m23s

Render reply trees with permission-aware inline controls, and move hunt, profile, voting, submission, and hiding flows to post storage.
This commit is contained in:
2026-08-27 07:40:14 -07:00
parent 4d994d5300
commit d3ce29031f
22 changed files with 1033 additions and 351 deletions
+40 -1
View File
@@ -59,7 +59,7 @@ func (s *Server) handleCreatePost(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r)
return
}
if !user.Admin() && user.ID != threadRoot.AuthorID {
if !canReplyToThread(user, threadRoot) {
http.Error(w, "forbidden", http.StatusForbidden)
return
}
@@ -175,3 +175,42 @@ func canEditPost(user *store.User, post *store.Post) bool {
}
return user.ID == post.AuthorID
}
func canReplyToThread(user *store.User, root *store.Post) bool {
return user != nil &&
root != nil &&
root.PostState != store.PostStateHidden &&
(user.Admin() || user.ID == root.AuthorID)
}
func postLabel(post *store.Post) string {
if post == nil {
return ""
}
if post.ParentID == nil {
return "Question"
}
if post.AuthorRole == store.RoleAdmin {
return "Shop response"
}
return "Homeowner"
}
func postDepthClass(depth int) string {
switch depth {
case 0:
return "root"
case 1:
return "branch"
default:
return "deep"
}
}
func postPointers(posts []store.Post) []*store.Post {
out := make([]*store.Post, len(posts))
for i := range posts {
out[i] = &posts[i]
}
return out
}