ping now returns both user and token privileges and their string representation

This commit is contained in:
Howl 2016-09-03 01:31:03 +02:00
parent 61527882d1
commit 9bfbb50ffd
2 changed files with 11 additions and 5 deletions

View File

@ -87,8 +87,11 @@ func surpriseMe() string {
type pingResponse struct {
common.ResponseBase
ID int `json:"user_id"`
Privileges uint64 `json:"privileges"`
ID int `json:"user_id"`
Privileges common.Privileges `json:"privileges"`
UserPrivileges common.UserPrivileges `json:"user_privileges"`
PrivilegesS string `json:"privileges_string"`
UserPrivilegesS string `json:"user_privileges_string"`
}
// PingGET is a message to check with the API that we are logged in, and know what are our privileges.
@ -103,7 +106,10 @@ func PingGET(md common.MethodData) common.CodeMessager {
}
r.ID = md.ID()
r.Privileges = uint64(md.User.TokenPrivileges)
r.Privileges = md.User.TokenPrivileges
r.UserPrivileges = md.User.UserPrivileges
r.PrivilegesS = md.User.TokenPrivileges.String()
r.UserPrivilegesS = md.User.UserPrivileges.String()
return r
}

View File

@ -34,7 +34,7 @@ SELECT users.id, users.username, register_datetime, privileges,
latest_activity, users_stats.username_aka,
users_stats.country
FROM users
LEFT JOIN users_stats
INNER JOIN users_stats
ON users.id=users_stats.id
WHERE ` + whereClause + ` AND ` + md.User.OnlyUserPublic(true) + `
LIMIT 1`
@ -98,7 +98,7 @@ type modeData struct {
Level float64 `json:"level"`
Accuracy float64 `json:"accuracy"`
PP int `json:"pp"`
GlobalLeaderboardRank int `json:"global_leaderboard_rank"`
GlobalLeaderboardRank *int `json:"global_leaderboard_rank"`
}
type userFullResponse struct {
common.ResponseBase