Adds points to user when action completed

This commit is contained in:
chopster44 committed 2023-07-21 23:02:59 +01:00
1 parent 0bdaac368c
commit 758c87652c
1 file changed
+13
+13
View File
@@ -133,6 +133,19 @@ func completeTask(c *gin.Context) {
c.IndentedJSON(http.StatusNotModified, completedTask)
return
}
// add points to user table
stmt, err = db.Prepare("UPDATE users SET points = points + ? WHERE uid=?")
if err != nil {
c.IndentedJSON(http.StatusNotModified, completedTask)
return
}
_, err = stmt.Exec(completedTask.PointsGained, completedTask.UID)
if err != nil {
c.IndentedJSON(http.StatusNotModified, completedTask)
return
}
c.IndentedJSON(http.StatusOK, completedTask)
}