diff options
Diffstat (limited to 'routes')
-rw-r--r-- | routes/node.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/routes/node.go b/routes/node.go index 2f5b7d3..e8aa455 100644 --- a/routes/node.go +++ b/routes/node.go @@ -77,9 +77,15 @@ func (r *Router) NewPost(c echo.Context) error { return c.Redirect(302, fmt.Sprintf("/t/%d#post%d", parentID, postID)) } - node, err := r.nodeRepo.Get(c.Request().Context(), parentID) - if err != nil { - return err + node := &models.Node{ + ID: 0, + Text: "Gorum", + } + if parentID > 0 { + node, err = r.nodeRepo.Get(c.Request().Context(), parentID) + if err != nil { + return err + } } return utils.Render(c, views.NewPost(node)) @@ -108,9 +114,15 @@ func (r *Router) NewTopic(c echo.Context) error { return c.Redirect(302, fmt.Sprintf("/t/%d", postID)) } - node, err := r.nodeRepo.Get(c.Request().Context(), parentID) - if err != nil { - return err + node := &models.Node{ + ID: 0, + Text: "Gorum", + } + if parentID > 0 { + node, err = r.nodeRepo.Get(c.Request().Context(), parentID) + if err != nil { + return err + } } return utils.Render(c, views.NewTopic(node)) |