From cefeeec11a996541aa4b977c547c7aac2bfeafd7 Mon Sep 17 00:00:00 2001 From: rawleyIfowler Date: Tue, 1 Mar 2022 16:15:22 -0600 Subject: [PATCH] adjusted spam filter to work for values around 20 characters, to stop spam of short proportions --- controllers/blog.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/blog.go b/controllers/blog.go index 11ddc94..6eb95fa 100644 --- a/controllers/blog.go +++ b/controllers/blog.go @@ -125,7 +125,8 @@ func CreateComment(c *gin.Context) { c.Request.Form.Get("content"), c.Request.Form.Get("url"), c.Request.Form.Get("captcha")} - if len(a[1]) > 180 && len(*GetCommentsByContent(a[1], a[2])) > 0 { + // If the length of the comment is great enough, and the comment already exists we can safely assume it is spam. + if len(a[1]) > 20 && len(*GetCommentsByContent(a[1], a[2])) > 0 { c.HTML(http.StatusNotAcceptable, "comment_post_failed.tmpl", CommentDto{Url: a[2]}) return }