diff --git a/controllers/blog.go b/controllers/blog.go index c45e76e..0660dfc 100644 --- a/controllers/blog.go +++ b/controllers/blog.go @@ -113,13 +113,14 @@ func CreateComment(c *gin.Context) { a := []string{c.Request.Form.Get("author"), c.Request.Form.Get("content"), c.Request.Form.Get("url")} + if GetNumberOfRecentPosts(c) > 3 { c.HTML(http.StatusOK, "comment_post_spam.tmpl", CommentDto{Url: a[2]}) return } for _, v := range a { if len(v) == 0 { - c.Status(http.StatusNotAcceptable) + c.HTML(http.StatusNotAcceptable, "comment_post_failed.tmpl", CommentDto{Url: a[2]}) return } } diff --git a/templates/comment_post_failed.tmpl b/templates/comment_post_failed.tmpl new file mode 100644 index 0000000..530a7b0 --- /dev/null +++ b/templates/comment_post_failed.tmpl @@ -0,0 +1,11 @@ +{{ template "header.tmpl" . }} +

Your comment failed to be posted...

+

You will be redirected or, click here to return to the blog post.

+ + + +