Skip to content

Commit

Permalink
Start using bumpThread function
Browse files Browse the repository at this point in the history
Fixes Issue #7.

Also adjust bumpThread to return any error it encounters to its caller.
Additionally, if bump is false in calls to insertPost, it will not bump the parent thread.
  • Loading branch information
onekopaka committed Jan 2, 2018
1 parent 7340a03 commit 97edf4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ func buildBoardListJSON() (html string) {

// bumps the given thread on the given board and returns true if it exists
// or false on error
func bumpThread(postID, boardID int) bool {
func bumpThread(postID, boardID int) error {
stmt, err := db.Prepare("UPDATE `" + config.DBprefix + "posts` SET `bumped` = ? WHERE `id` = ? AND `boardid` = ?")
if err != nil {
return false
return err
}
defer func() {
if stmt != nil {
Expand All @@ -718,9 +718,9 @@ func bumpThread(postID, boardID int) bool {

_, err = stmt.Exec(time.Now(), postID, boardID)
if err != nil {
return false
return err
}
return true
return nil
}

// Checks check poster's name/tripcode/file checksum (from PostTable post) for banned status
Expand Down Expand Up @@ -888,12 +888,12 @@ func insertPost(post PostTable, bump bool) (sql.Result, error) {
return result, err
}

if post.ParentID != 0 {
stmt, err = db.Prepare("UPDATE `" + config.DBprefix + "posts` SET `bumped` = ? WHERE `id` = ?")
// Bump parent post if requested.
if post.ParentID != 0 && bump {
err = bumpThread(post.ParentID, post.BoardID)
if err != nil {
return nil, err
}
result, err = stmt.Exec(getSpecificSQLDateTime(post.Bumped), post.ParentID)
}
return result, err
}
Expand Down

0 comments on commit 97edf4d

Please sign in to comment.