|
|
@ -27,6 +27,7 @@ func getVoteName(id int) (string, error) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defer rows.Close()
|
|
|
|
if rows.Next() {
|
|
|
|
if rows.Next() {
|
|
|
|
var name string
|
|
|
|
var name string
|
|
|
|
err := rows.Scan(&name)
|
|
|
|
err := rows.Scan(&name)
|
|
|
@ -43,6 +44,7 @@ func getVoteFromMessageID(msgID string) (int, error) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defer rows.Close()
|
|
|
|
if rows.Next() {
|
|
|
|
if rows.Next() {
|
|
|
|
var id int
|
|
|
|
var id int
|
|
|
|
err := rows.Scan(&id)
|
|
|
|
err := rows.Scan(&id)
|
|
|
@ -64,10 +66,12 @@ func updateVote(voteID int, userID string, voteValue int) error {
|
|
|
|
if rows.Next() {
|
|
|
|
if rows.Next() {
|
|
|
|
return errForceRejectionVoteReuse
|
|
|
|
return errForceRejectionVoteReuse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rows.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Check if the vote is finished and don't allow change of vote that way.
|
|
|
|
//Check if the vote is finished and don't allow change of vote that way.
|
|
|
|
rows, err := db.Query("SELECT finished FROM vote WHERE id=? AND finished=?", voteID, true)
|
|
|
|
rows, err := db.Query("SELECT finished FROM vote WHERE id=? AND finished=?", voteID, true)
|
|
|
|
|
|
|
|
defer rows.Close()
|
|
|
|
if rows.Next() {
|
|
|
|
if rows.Next() {
|
|
|
|
return errVoteIsOver
|
|
|
|
return errVoteIsOver
|
|
|
|
}
|
|
|
|
}
|
|
|
|