1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

frontend,api: open source comment sticky

This commit is contained in:
Adhityaa Chandrasekar
2018-12-18 18:57:32 -05:00
parent cf0b394b05
commit 610b61831d
6 changed files with 88 additions and 11 deletions

View File

@ -11,20 +11,21 @@ func pageGet(domain string, path string) (page, error) {
}
statement := `
SELECT isLocked, commentCount
SELECT isLocked, commentCount, stickyCommentHex
FROM pages
WHERE domain=$1 AND path=$2;
`
row := db.QueryRow(statement, domain, path)
p := page{Domain: domain, Path: path}
if err := row.Scan(&p.IsLocked, &p.CommentCount); err != nil {
if err := row.Scan(&p.IsLocked, &p.CommentCount, &p.StickyCommentHex); err != nil {
if err == sql.ErrNoRows {
// If there haven't been any comments, there won't be a record for this
// page. The sane thing to do is return defaults.
// TODO: the defaults are hard-coded in two places: here and the schema
p.IsLocked = false
p.CommentCount = 0
p.StickyCommentHex = "none"
} else {
logger.Errorf("error scanning page: %v", err)
return page{}, errorInternal