Skip to content

Commit

Permalink
fix: hanayo passes id as string lol (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku authored Nov 5, 2023
1 parent d5509f9 commit 5b83fdc
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/v1/user_scores.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"fmt"
"strings"
"strconv"

"github.com/osuAkatsuki/akatsuki-api/common"
"gopkg.in/thehowl/go-osuapi.v1"
Expand Down Expand Up @@ -218,12 +219,17 @@ func ScoresPinAddPOST(md common.MethodData) common.CodeMessager {
}

var u struct {
ID int `json:"id"`
ID string `json:"id"`
Relax int `json:"rx"`
}
md.Unmarshal(&u)

return pinScore(md, u.ID, u.Relax, md.ID())
id, err := strconv.ParseInt(u.ID, 10, 64)
if err != nil {
panic(err)
}

return pinScore(md, id, u.Relax, md.ID())
}

func ScoresPinDelPOST(md common.MethodData) common.CodeMessager {
Expand All @@ -232,15 +238,20 @@ func ScoresPinDelPOST(md common.MethodData) common.CodeMessager {
}

var u struct {
ID int `json:"id"`
ID string `json:"id"`
Relax int `json:"rx"`
}
md.Unmarshal(&u)

return unpinScore(md, u.ID, u.Relax, md.ID())
id, err := strconv.ParseInt(u.ID, 10, 64)
if err != nil {
panic(err)
}

return unpinScore(md, id, u.Relax, md.ID())
}

func pinScore(md common.MethodData, id int, relax int, userId int) common.CodeMessager {
func pinScore(md common.MethodData, id int64, relax int, userId int) common.CodeMessager {
var table string
if relax == 1 {
table = "scores_relax"
Expand Down Expand Up @@ -269,7 +280,7 @@ func pinScore(md common.MethodData, id int, relax int, userId int) common.CodeMe
return common.SimpleResponse(200, "Score pinned.")
}

func unpinScore(md common.MethodData, id int, relax int, userId int) common.CodeMessager {
func unpinScore(md common.MethodData, id int64, relax int, userId int) common.CodeMessager {
var table string
if relax == 1 {
table = "scores_relax"
Expand Down

0 comments on commit 5b83fdc

Please sign in to comment.