oops, allow saving edit too
Ted Unangst tedu@tedunangst.com
Wed, 09 Oct 2019 16:16:38 -0400
1 files changed,
10 insertions(+),
3 deletions(-)
jump to
M
web.go
→
web.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