aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-11-07 11:35:00 +0300
committerGitHub <noreply@github.com>2023-11-07 11:35:00 +0300
commitc6cfaa59b0d5b005966355410abd745268a236e4 (patch)
treed7a382f5537c5f298d6cbeb99fadd9dbac43b6b2 /backend
parentfeat: inline parser instead of executable (#113) (diff)
downloadlphub-c6cfaa59b0d5b005966355410abd745268a236e4.tar.gz
lphub-c6cfaa59b0d5b005966355410abd745268a236e4.tar.bz2
lphub-c6cfaa59b0d5b005966355410abd745268a236e4.zip
fix: getplayersummaries cant unmarshal when player is in game (#131)
Diffstat (limited to 'backend')
-rw-r--r--backend/handlers/login.go10
-rw-r--r--backend/models/models.go25
2 files changed, 9 insertions, 26 deletions
diff --git a/backend/handlers/login.go b/backend/handlers/login.go
index 1a74166..a6e99bd 100644
--- a/backend/handlers/login.go
+++ b/backend/handlers/login.go
@@ -145,15 +145,15 @@ func DeleteCookie(c *gin.Context) {
145 }) 145 })
146} 146}
147 147
148func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) { 148func GetPlayerSummaries(steamId, apiKey string) (models.PlayerSummaries, error) {
149 url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId) 149 url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId)
150 resp, err := http.Get(url) 150 resp, err := http.Get(url)
151 if err != nil { 151 if err != nil {
152 return nil, err 152 return models.PlayerSummaries{}, err
153 } 153 }
154 body, err := io.ReadAll(resp.Body) 154 body, err := io.ReadAll(resp.Body)
155 if err != nil { 155 if err != nil {
156 return nil, err 156 return models.PlayerSummaries{}, err
157 } 157 }
158 158
159 type Result struct { 159 type Result struct {
@@ -163,7 +163,7 @@ func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error)
163 } 163 }
164 var data Result 164 var data Result
165 if err := json.Unmarshal(body, &data); err != nil { 165 if err := json.Unmarshal(body, &data); err != nil {
166 return nil, err 166 return models.PlayerSummaries{}, err
167 } 167 }
168 return &data.Response.Players[0], err 168 return data.Response.Players[0], err
169} 169}
diff --git a/backend/models/models.go b/backend/models/models.go
index 3aa2e9c..bf3ac86 100644
--- a/backend/models/models.go
+++ b/backend/models/models.go
@@ -122,25 +122,8 @@ type Pagination struct {
122} 122}
123 123
124type PlayerSummaries struct { 124type PlayerSummaries struct {
125 SteamId string `json:"steamid"` 125 SteamId string `json:"steamid"`
126 CommunityVisibilityState int `json:"communityvisibilitystate"` 126 PersonaName string `json:"personaname"`
127 ProfileState int `json:"profilestate"` 127 AvatarFull string `json:"avatarfull"`
128 PersonaName string `json:"personaname"` 128 LocCountryCode string `json:"loccountrycode"`
129 LastLogOff int `json:"lastlogoff"`
130 ProfileUrl string `json:"profileurl"`
131 Avatar string `json:"avatar"`
132 AvatarMedium string `json:"avatarmedium"`
133 AvatarFull string `json:"avatarfull"`
134 PersonaState int `json:"personastate"`
135
136 CommentPermission int `json:"commentpermission"`
137 RealName string `json:"realname"`
138 PrimaryClanId string `json:"primaryclanid"`
139 TimeCreated int `json:"timecreated"`
140 LocCountryCode string `json:"loccountrycode"`
141 LocStateCode string `json:"locstatecode"`
142 LocCityId int `json:"loccityid"`
143 GameId int `json:"gameid"`
144 GameExtraInfo string `json:"gameextrainfo"`
145 GameServerIp string `json:"gameserverip"`
146} 129}