allow passing comment.ID for import

This commit is contained in:
eugene
2017-12-23 13:30:01 -06:00
parent 4da52f2c07
commit 60d2b30907
2 changed files with 7 additions and 3 deletions
+3 -2
View File
@@ -105,6 +105,9 @@ func (s *Server) createCommentCtrl(w http.ResponseWriter, r *http.Request) {
return
}
comment.ID = "" // don't allow user to define ID, force auto-gen
comment.Text = template.HTMLEscapeString(comment.Text)
comment.User.IP = strings.Split(r.RemoteAddr, ":")[0]
comment.User.ID = template.HTMLEscapeString(user.ID)
comment.User.Name = template.HTMLEscapeString(user.Name)
@@ -112,8 +115,6 @@ func (s *Server) createCommentCtrl(w http.ResponseWriter, r *http.Request) {
comment.User.Profile = template.HTMLEscapeString(user.Profile)
comment.User.Admin = user.Admin
comment.Text = template.HTMLEscapeString(comment.Text)
log.Printf("[INFO] create comment %+v", comment)
// check if user blocked
+4 -1
View File
@@ -42,7 +42,10 @@ func NewBoltDB(dbFile string) (*BoltDB, error) {
// Create saves new comment to store
func (b *BoltDB) Create(comment Comment) (string, error) {
comment.ID = makeCommentID()
if comment.ID == "" {
comment.ID = makeCommentID()
}
comment.Timestamp = time.Now()
comment.Votes = make(map[string]bool)