1
0

Create new category implemented.

This commit is contained in:
Alexander Andreev 2023-05-14 03:51:35 +04:00
parent 5b4cc67fda
commit 83720a317e
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -230,7 +230,11 @@ func (h *MindflowApiHandlers) New(w http.ResponseWriter, r *http.Request) {
category_id, _ := strconv.ParseInt(r.FormValue("category"), 10, 64)
if category_id == 0 {
// TODO: create category
category_id, err = h.db.NewCategory(r.FormValue("new-category"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
post, err = mindflow.NewPost(mindflow.Category{ID: category_id}, r.FormValue("title"), r.FormValue("body"))