Skip to content

Commit

Permalink
Votes check for post creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekrikorian committed Feb 4, 2019
1 parent 07fb461 commit 57dc07b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/api.go
Expand Up @@ -203,6 +203,11 @@ func CreatePost(w http.ResponseWriter, r *http.Request) {
post.UserID = userID
post.Title = strings.TrimSpace(post.Title)

if post.Votes > 0 {
http.Error(w, "Nice try buddie...", 500)
return
}

if l := len(post.Title); l < 3 || l > 140 {
http.Error(w, "Title must be within 3 and 140 characters", 500)
return
Expand Down

0 comments on commit 57dc07b

Please sign in to comment.