From 04c65dcc0f83aa67c6eafbf4af9531bbeb9fd6ca Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 9 Oct 2019 16:16:38 -0400 Subject: [PATCH] oops, allow saving edit too --- web.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web.go b/web.go index d69e137..00e1544 100644 --- a/web.go +++ b/web.go @@ -902,7 +902,7 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) { user, _ := butwhatabout(u.Username) xid := r.FormValue("xid") honk := getxonk(u.UserID, xid) - if honk == nil || honk.Honker != user.URL || honk.What == "bonk" { + if !canedithonk(user, honk) { http.Error(w, "no editing that please", http.StatusInternalServerError) return } @@ -930,6 +930,13 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) { } } +func canedithonk(user *WhatAbout, honk *Honk) bool { + if honk == nil || honk.Honker != user.URL || honk.What == "bonk" { + return false + } + return true +} + // what a hot mess this function is func submithonk(w http.ResponseWriter, r *http.Request) { rid := r.FormValue("rid") @@ -943,8 +950,8 @@ func submithonk(w http.ResponseWriter, r *http.Request) { var honk *Honk if updatexid != "" { honk = getxonk(userinfo.UserID, updatexid) - if honk == nil || honk.Honker != user.URL || honk.What != "honk" { - log.Printf("not saving edit") + if !canedithonk(user, honk) { + http.Error(w, "no editing that please", http.StatusInternalServerError) return } honk.Date = dt