prevent user from voting for they own comments

This commit is contained in:
Umputun
2018-05-11 16:10:11 -05:00
parent 1b8e0c0cf3
commit db7f4c84bf
+4
View File
@@ -58,6 +58,10 @@ func (s *Service) Vote(locator Locator, commentID string, userID string, val boo
return comment, err
}
if comment.User.ID == userID {
return comment, errors.Errorf("user %s can not vote for his own comment %s", userID, commentID)
}
if comment.Votes == nil {
comment.Votes = make(map[string]bool)
}