all repos — honk @ a96588b4643747fab14389ce3c8b13ed31f590fe

my fork of honk

oops, allow saving edit too
Ted Unangst tedu@tedunangst.com
Wed, 09 Oct 2019 16:16:38 -0400
commit

a96588b4643747fab14389ce3c8b13ed31f590fe

parent

2d015421d887b4da87dba20410be9554026d5968

1 files changed, 10 insertions(+), 3 deletions(-)

jump to
M web.goweb.go

@@ -902,7 +902,7 @@ u := login.GetUserInfo(r)

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 @@ log.Print(err)

} } +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 @@ updatexid := r.FormValue("updatexid")

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