comment_new.go: create page before inserting comment
Fixes https://gitlab.com/commento/commento/issues/173
This commit is contained in:
parent
ff04981cf5
commit
62340eb9c6
@ -20,8 +20,8 @@ func TestCommentCountBasics(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if counts["/path.html"] != 2 {
|
if counts["/path.html"] != 3 {
|
||||||
t.Errorf("expected count=2 got count=%d", counts["/path.html"])
|
t.Errorf("expected count=3 got count=%d", counts["/path.html"])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ func commentNew(commenterHex string, domain string, path string, parentHex strin
|
|||||||
|
|
||||||
html := markdownToHtml(markdown)
|
html := markdownToHtml(markdown)
|
||||||
|
|
||||||
|
if err = pageNew(domain, path); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
statement := `
|
statement := `
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
comments (commentHex, domain, path, commenterHex, parentHex, markdown, html, creationDate, state)
|
comments (commentHex, domain, path, commenterHex, parentHex, markdown, html, creationDate, state)
|
||||||
@ -41,10 +45,6 @@ func commentNew(commenterHex string, domain string, path string, parentHex strin
|
|||||||
return "", errorInternal
|
return "", errorInternal
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = pageNew(domain, path); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return commentHex, nil
|
return commentHex, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
db/20190508222848-reset-count.sql
Normal file
2
db/20190508222848-reset-count.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
UPDATE pages
|
||||||
|
SET commentCount = commentCount + 1;
|
Loading…
Reference in New Issue
Block a user