1
0

Handler for reply new and update (doesn't work yet).

This commit is contained in:
Alexander Andreev 2023-02-06 02:43:26 +04:00
parent 37c56a91b6
commit 4efc83b09e
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -201,10 +201,34 @@ func (h *Handlers) GuestbookAdminDeleteReply(w http.ResponseWriter, r *http.Requ
}
}
func (h *Handlers) GuestbookAdminUpdateReply(w http.ResponseWriter, r *http.Request) {
}
func (h *Handlers) GuestbookAdminReply(w http.ResponseWriter, r *http.Request) {
func (h *Handlers) GuestbookAdminNewReply(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
id, err := strconv.ParseInt(r.FormValue("entry_id"), 10, 64)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
reply, err := guestbook.NewReply(id, r.FormValue("message"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if r.URL.Query().Has("update") {
if err = h.guestbookDB.UpdateReply(reply); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} else {
err = h.guestbookDB.NewReply(reply)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
}
func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {