feat: make sage possible

This commit is contained in:
Yanislav Igonin 2021-10-07 10:51:18 +03:00
parent 10207952e2
commit 89487cda3b
3 changed files with 5 additions and 3 deletions

View File

@ -254,7 +254,7 @@ func UpdateThread(c *gin.Context) {
if len(isSageField) != 0 {
isSageString = isSageField[0]
}
isSage := isSageString == "true"
isSage := isSageString == "on"
conn, err := Db.Pool.Acquire(context.TODO())
if err != nil {

View File

@ -188,7 +188,7 @@ func (r *PostsRepository) CreateInTx(tx pgx.Tx, p Post) (int, error) {
}
// updating parent post `updated_at`
if !p.IsParent {
if !p.IsParent && !p.IsSage {
sql = `
UPDATE posts
SET updated_at = now()
@ -197,6 +197,8 @@ func (r *PostsRepository) CreateInTx(tx pgx.Tx, p Post) (int, error) {
row := tx.QueryRow(context.TODO(), sql, p.ParentID)
var msg string
err = row.Scan(&msg)
// UPDATE always return `no rows`
// so we need to check this condition
if err != nil && err != pgx.ErrNoRows {
return 0, err
}

View File

@ -24,7 +24,7 @@
<div class="row">
{{ if ne .FirstPostID 0 }}
<div class="col">
<input class="form-check-input" type="checkbox" value="" id="postSage" name="sage">
<input class="form-check-input" type="checkbox" value="on" id="postSage" name="sage">
<label class="form-check-label" for="postSage">
Sage
</label>