From 9bd050fac2f4980205de42eb1ff7e00a08ee946d Mon Sep 17 00:00:00 2001 From: Andrei Mihu Date: Mon, 19 Mar 2018 20:28:59 +0000 Subject: [PATCH] Add extra fields to runtime user account retrieval. --- server/runtime_nakama_module.go | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/server/runtime_nakama_module.go b/server/runtime_nakama_module.go index 5463eed74..f0ffc7f44 100644 --- a/server/runtime_nakama_module.go +++ b/server/runtime_nakama_module.go @@ -1128,7 +1128,7 @@ func (n *NakamaModule) usersGetId(l *lua.LState) int { // Convert and push the values. usersTable := l.CreateTable(len(users.Users), 0) for i, u := range users.Users { - ut := l.CreateTable(0, 10) + ut := l.CreateTable(0, 16) ut.RawSetString("user_id", lua.LString(u.Id)) ut.RawSetString("username", lua.LString(u.Username)) ut.RawSetString("display_name", lua.LString(u.DisplayName)) @@ -1136,6 +1136,20 @@ func (n *NakamaModule) usersGetId(l *lua.LState) int { ut.RawSetString("lang_tag", lua.LString(u.LangTag)) ut.RawSetString("location", lua.LString(u.Location)) ut.RawSetString("timezone", lua.LString(u.Timezone)) + if u.FacebookId != "" { + ut.RawSetString("facebook_id", lua.LString(u.FacebookId)) + } + if u.GoogleId != "" { + ut.RawSetString("google_id", lua.LString(u.GoogleId)) + } + if u.GamecenterId != "" { + ut.RawSetString("gamecenter_id", lua.LString(u.GamecenterId)) + } + if u.SteamId != "" { + ut.RawSetString("steam_id", lua.LString(u.SteamId)) + } + ut.RawSetString("online", lua.LBool(u.Online)) + ut.RawSetString("edge_count", lua.LNumber(u.EdgeCount)) ut.RawSetString("create_time", lua.LNumber(u.CreateTime.Seconds)) ut.RawSetString("update_time", lua.LNumber(u.UpdateTime.Seconds)) @@ -1193,7 +1207,7 @@ func (n *NakamaModule) usersGetUsername(l *lua.LState) int { // Convert and push the values. usersTable := l.CreateTable(len(users.Users), 0) for i, u := range users.Users { - ut := l.CreateTable(0, 10) + ut := l.CreateTable(0, 16) ut.RawSetString("user_id", lua.LString(u.Id)) ut.RawSetString("username", lua.LString(u.Username)) ut.RawSetString("display_name", lua.LString(u.DisplayName)) @@ -1201,6 +1215,20 @@ func (n *NakamaModule) usersGetUsername(l *lua.LState) int { ut.RawSetString("lang_tag", lua.LString(u.LangTag)) ut.RawSetString("location", lua.LString(u.Location)) ut.RawSetString("timezone", lua.LString(u.Timezone)) + if u.FacebookId != "" { + ut.RawSetString("facebook_id", lua.LString(u.FacebookId)) + } + if u.GoogleId != "" { + ut.RawSetString("google_id", lua.LString(u.GoogleId)) + } + if u.GamecenterId != "" { + ut.RawSetString("gamecenter_id", lua.LString(u.GamecenterId)) + } + if u.SteamId != "" { + ut.RawSetString("steam_id", lua.LString(u.SteamId)) + } + ut.RawSetString("online", lua.LBool(u.Online)) + ut.RawSetString("edge_count", lua.LNumber(u.EdgeCount)) ut.RawSetString("create_time", lua.LNumber(u.CreateTime.Seconds)) ut.RawSetString("update_time", lua.LNumber(u.UpdateTime.Seconds)) -- GitLab