Implement per board post number incrementing

This commit is contained in:
Dominic Ferrando
2025-04-21 12:33:19 -04:00
parent 4e4b5614e0
commit 151b740ee9
6 changed files with 44 additions and 25 deletions
+2 -5
View File
@@ -78,7 +78,6 @@ func main() {
// THREAD PAGE
r.Get("/{slug}/threads/{threadId}", func(w http.ResponseWriter, r *http.Request) {
slug := chi.URLParam(r, "slug")
// TODO: use relative thread_nums (see issue #1)
threadIdStr := chi.URLParam(r, "threadId")
threadId, err := strconv.Atoi(threadIdStr)
if err != nil {
@@ -165,8 +164,7 @@ func main() {
return
}
// slug := chi.URLParam(r, "slug")
// TODO: use relative thread_nums (see issue #1)
slug := chi.URLParam(r, "slug")
threadIdStr := chi.URLParam(r, "threadId")
threadId, err := strconv.Atoi(threadIdStr)
if err != nil {
@@ -201,7 +199,7 @@ func main() {
mediaPath = filename
}
if err := database.PutPost(db, threadId, body, mediaPath, util.HashIp(ip)); err != nil {
if err := database.PutPost(db, slug, threadId, body, mediaPath, util.HashIp(ip)); err != nil {
http.Error(w, "Failed to create post", http.StatusInternalServerError)
log.Printf("PutPost: %v", err)
return
@@ -256,7 +254,6 @@ func main() {
// THREAD POSTS
r.Get("/hx/{slug}/threads/{threadId}/posts", func(w http.ResponseWriter, r *http.Request) {
// slug := chi.URLParam(r, "slug")
// TODO: use relative thread_nums (see issue #1)
threadIdStr := chi.URLParam(r, "threadId")
threadId, err := strconv.Atoi(threadIdStr)
if err != nil {