From 1d6f063be549fdc0c1cd20a417bb5a980a2e6b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Fernandes?= Date: Mon, 31 Jul 2023 17:48:28 +0100 Subject: [PATCH] Add 'recompute' param to Satori's update-properties --- go.mod | 2 +- go.sum | 4 ++++ server/runtime_javascript_nakama.go | 8 ++++++++ server/runtime_lua_nakama.go | 8 ++++++++ .../heroiclabs/nakama-common/runtime/runtime.go | 5 +++-- vendor/modules.txt | 2 +- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index aca39f5349..1258b150a1 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 - github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380 + github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c github.com/jackc/pgconn v1.14.0 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa github.com/jackc/pgtype v1.14.0 diff --git a/go.sum b/go.sum index 72336a2d4e..97a3a6d551 100644 --- a/go.sum +++ b/go.sum @@ -296,6 +296,10 @@ github.com/heroiclabs/nakama-common v1.28.0 h1:oj6voT/3xOkOjeWzPVkrH0ATakZT6WNLL github.com/heroiclabs/nakama-common v1.28.0/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs= github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380 h1:cPpoIEukbm0RmM7jzLApRVYQeZp9G1Sg1RsvyxcJ0d4= github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs= +github.com/heroiclabs/nakama-common v1.28.1-0.20230731165244-63a5a47100ee h1:rDI4A+kMhbE5xzMdWYiDHAavt6zOa7ZjmShNUE2WafI= +github.com/heroiclabs/nakama-common v1.28.1-0.20230731165244-63a5a47100ee/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs= +github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c h1:WYodhJ3/FcxNkYHTH4QT07IFM48VTcg5R88f99xeL3I= +github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= diff --git a/server/runtime_javascript_nakama.go b/server/runtime_javascript_nakama.go index 2d1b9e63d2..29351c2256 100644 --- a/server/runtime_javascript_nakama.go +++ b/server/runtime_javascript_nakama.go @@ -8294,6 +8294,14 @@ func (n *runtimeJavascriptNakamaModule) satoriPropertiesUpdate(r *goja.Runtime) properties.Custom = customPropsMap } + if recompute, ok := props["recomputeAudiences"]; ok { + recomputeBool, ok := recompute.(bool) + if !ok { + panic(r.NewTypeError("expects recomputeAudiences to be a boolean")) + } + properties.RecomputeAudiences = &recomputeBool + } + if err := n.satori.PropertiesUpdate(n.ctx, id, properties); err != nil { panic(r.NewGoError(fmt.Errorf("failed to satori update properties: %s", err.Error()))) } diff --git a/server/runtime_lua_nakama.go b/server/runtime_lua_nakama.go index ca2d9b5cc1..316d5351a4 100644 --- a/server/runtime_lua_nakama.go +++ b/server/runtime_lua_nakama.go @@ -9986,6 +9986,14 @@ func (n *RuntimeLuaNakamaModule) satoriPropertiesUpdate(l *lua.LState) int { return } properties.Custom = customMap + case "recomputeAudiences": + if v.Type() != lua.LTBool { + conversionError = true + l.ArgError(3, "expects recomputeAudiences value to be a bool") + return + } + recomputeAudiences := lua.LVAsBool(v) + properties.RecomputeAudiences = &recomputeAudiences } }) diff --git a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go index bf6418d15b..ad258e89d3 100644 --- a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go +++ b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go @@ -1167,8 +1167,9 @@ type Properties struct { } type PropertiesUpdate struct { - Default map[string]string `json:"default,omitempty"` - Custom map[string]string `json:"custom,omitempty"` + Default map[string]string `json:"default,omitempty"` + Custom map[string]string `json:"custom,omitempty"` + Recompute *bool `json:"recompute,omitempty"` } type Events struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index 30642af474..c61a240fca 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -151,7 +151,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopena github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities -# github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380 +# github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c ## explicit; go 1.19 github.com/heroiclabs/nakama-common/api github.com/heroiclabs/nakama-common/rtapi