started adding the actual creation of the topic in the database (incomplete)

This commit is contained in:
2025-11-06 23:12:17 -07:00
parent 9bd8045e8c
commit 161e51a640
2 changed files with 116 additions and 0 deletions
+29
View File
@@ -266,7 +266,36 @@ func NewTopic(ctxt ui.AmContext) (string, any, error) {
return "framed_template", "new_topic.jet", nil
}
if ctxt.FormFieldIsSet("post1") {
// start by checking the title and pseud
checker, err := htmlcheck.AmNewHTMLChecker("post-pseud")
if err != nil {
return ui.ErrorPage(ctxt, err)
}
checker.Append(ctxt.FormField("title"))
checker.Finish()
topicName, _ := checker.Value()
checker.Reset()
checker.Append(ctxt.FormField("pseud"))
checker.Finish()
zeroPostPseud, _ := checker.Value()
// now check the post data itself
checker, err = htmlcheck.AmNewHTMLChecker("post-body")
if err != nil {
return ui.ErrorPage(ctxt, err)
}
checker.SetContext("PostLinkDecoderContext", database.AmCreatePostLinkContext(comm.Alias, ctxt.URLParam("cid"), conf.TopTopic+1))
checker.Append(ctxt.FormField("pb"))
checker.Finish()
zeroPost, _ := checker.Value()
lines, _ := checker.Lines()
// Add the topic!
topic, err := database.AmNewTopic(conf, ctxt.CurrentUser(), topicName, zeroPostPseud, zeroPost, int32(lines))
if err != nil {
return ui.ErrorPage(ctxt, err)
}
_ = topic // TODO
}
return ui.ErrorPage(ctxt, errors.New("invalid button clicked on form"))