allow passing timestamp to create, clear on rest level
This commit is contained in:
+7
-1
@@ -101,7 +101,13 @@ func importComments(dataStore store.Interface) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "can't open import file %s", opts.ImportCommand.InputFile)
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
defer func() {
|
||||
if err = fh.Close(); err != nil {
|
||||
log.Printf("[WARN] can't close %s, %s", opts.ImportCommand.InputFile, err)
|
||||
}
|
||||
}()
|
||||
|
||||
return importer.Import(fh, opts.ImportCommand.SiteID)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,6 @@ type Disqus struct {
|
||||
DataStore store.Interface
|
||||
}
|
||||
|
||||
type disqusXML struct {
|
||||
Threads []disqusThread `xml:"thread"`
|
||||
Comments []disqusComment `xml:"post"`
|
||||
}
|
||||
|
||||
type disqusThread struct {
|
||||
UID string `xml:"id,attr"`
|
||||
Forum string `xml:"forum"`
|
||||
|
||||
+2
-1
@@ -105,7 +105,8 @@ func (s *Server) createCommentCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
comment.ID = "" // don't allow user to define ID, force auto-gen
|
||||
comment.ID = "" // don't allow user to define ID, force auto-gen
|
||||
comment.Timestamp = time.Time{} // reset time, force auto-gen
|
||||
comment.Text = template.HTMLEscapeString(comment.Text)
|
||||
|
||||
comment.User.IP = strings.Split(r.RemoteAddr, ":")[0]
|
||||
|
||||
+3
-1
@@ -44,8 +44,10 @@ func (b *BoltDB) Create(comment Comment) (string, error) {
|
||||
if comment.ID == "" {
|
||||
comment.ID = makeCommentID()
|
||||
}
|
||||
if comment.Timestamp.IsZero() {
|
||||
comment.Timestamp = time.Now()
|
||||
}
|
||||
|
||||
comment.Timestamp = time.Now()
|
||||
comment.Votes = make(map[string]bool)
|
||||
|
||||
err := b.Update(func(tx *bolt.Tx) error {
|
||||
|
||||
Reference in New Issue
Block a user