From 7fada7ee23cfb3dcd1d7209d2fdb3f40479f67e7 Mon Sep 17 00:00:00 2001 From: Andrei Mihu Date: Mon, 29 Mar 2021 20:33:43 +0100 Subject: [PATCH] Improve social package struct field alignment. --- server/api_test.go | 5 +++-- server/core_wallet_test.go | 14 +++++++------- server/runtime_test.go | 4 ++-- social/social.go | 10 +++++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/server/api_test.go b/server/api_test.go index f84d70fff..7373499f5 100644 --- a/server/api_test.go +++ b/server/api_test.go @@ -24,6 +24,7 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/heroiclabs/nakama-common/api" "github.com/heroiclabs/nakama-common/rtapi" + "github.com/heroiclabs/nakama-common/runtime" "github.com/heroiclabs/nakama/v3/apigrpc" _ "github.com/jackc/pgx/stdlib" "go.uber.org/zap" @@ -108,7 +109,7 @@ func (d *DummySession) SendBytes(payload []byte, reliable bool) error { return nil } -func (d *DummySession) Close(reason string) {} +func (d *DummySession) Close(msg string, reason runtime.PresenceReason) {} type loggerEnabler struct{} @@ -167,7 +168,7 @@ func NewAPIServer(t *testing.T, runtime *Runtime) (*ApiServer, *Pipeline) { router := &DummyMessageRouter{} tracker := &LocalTracker{} pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, tracker, router, runtime) - apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, tracker, router, metrics, pipeline, runtime) + apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, tracker, router, metrics, pipeline, runtime) return apiServer, pipeline } diff --git a/server/core_wallet_test.go b/server/core_wallet_test.go index 9a4a537ee..e65dd74f2 100644 --- a/server/core_wallet_test.go +++ b/server/core_wallet_test.go @@ -70,7 +70,7 @@ func TestUpdateWalletSingleUser(t *testing.T) { } db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) userID, _, _, err := AuthenticateCustom(context.Background(), logger, db, uuid.Must(uuid.NewV4()).String(), uuid.Must(uuid.NewV4()).String(), true) if err != nil { @@ -148,7 +148,7 @@ func TestUpdateWalletMultiUser(t *testing.T) { } db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) count := 5 userIDs := make([]string, 0, count) @@ -235,7 +235,7 @@ func TestUpdateWalletsMultiUser(t *testing.T) { } db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) count := 5 userIDs := make([]string, 0, count) @@ -327,7 +327,7 @@ func TestUpdateWalletsMultiUserSharedChangeset(t *testing.T) { } db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) count := 5 userIDs := make([]string, 0, count) @@ -423,7 +423,7 @@ func TestUpdateWalletsMultiUserSharedChangesetDeductions(t *testing.T) { } db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) count := 5 userIDs := make([]string, 0, count) @@ -478,7 +478,7 @@ func TestUpdateWalletsMultiUserSharedChangesetDeductions(t *testing.T) { func TestUpdateWalletsSingleUser(t *testing.T) { db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) userID, _, _, err := AuthenticateCustom(context.Background(), logger, db, uuid.Must(uuid.NewV4()).String(), uuid.Must(uuid.NewV4()).String(), true) if err != nil { @@ -525,7 +525,7 @@ func TestUpdateWalletsSingleUser(t *testing.T) { func TestUpdateWalletRepeatedSingleUser(t *testing.T) { db := NewDB(t) - nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nk := NewRuntimeGoNakamaModule(logger, db, nil, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) userID, _, _, err := AuthenticateCustom(context.Background(), logger, db, uuid.Must(uuid.NewV4()).String(), uuid.Must(uuid.NewV4()).String(), true) if err != nil { diff --git a/server/runtime_test.go b/server/runtime_test.go index 8cfd66110..dac77f24c 100644 --- a/server/runtime_test.go +++ b/server/runtime_test.go @@ -77,7 +77,7 @@ func runtimeWithModules(t *testing.T, modules map[string]string) (*Runtime, *Run cfg := NewConfig(logger) cfg.Runtime.Path = dir - return NewRuntime(logger, logger, NewDB(t), jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, metrics, nil, &DummyMessageRouter{}) + return NewRuntime(logger, logger, NewDB(t), jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, metrics, nil, &DummyMessageRouter{}) } func TestRuntimeSampleScript(t *testing.T) { @@ -355,7 +355,7 @@ nakama.register_rpc(test.printWorld, "helloworld")`, db := NewDB(t) pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, nil, nil, runtime) - apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, metrics, pipeline, runtime) + apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, metrics, pipeline, runtime) defer apiServer.Stop() payload := "\"Hello World\"" diff --git a/social/social.go b/social/social.go index baaabc594..707a6b461 100644 --- a/social/social.go +++ b/social/social.go @@ -66,14 +66,14 @@ type JwksCerts struct { // JWK certificate data for an Apple Sign In verification key. type JwksCert struct { + key *rsa.PublicKey + Kty string `json:"kty"` Kid string `json:"kid"` Use string `json:"use"` Alg string `json:"alg"` N string `json:"n"` E string `json:"e"` - - key *rsa.PublicKey } // AppleProfile is an abbreviated version of a user authenticated through Apple Sign In. @@ -103,8 +103,8 @@ type facebookPaging struct { } type facebookFriends struct { - Data []FacebookProfile `json:"data"` Paging facebookPaging `json:"paging"` + Data []FacebookProfile `json:"data"` } // GoogleProfile is an abbreviated version of a Google profile extracted from in a verified ID token. @@ -141,8 +141,8 @@ type steamFriendsWrapper struct { // SteamError contains a possible error response from the Steam Web API. type SteamError struct { - ErrorCode int `json:"errorcode"` ErrorDesc string `json:"errordesc"` + ErrorCode int `json:"errorcode"` } // Unwrapping the SteamProfile @@ -276,9 +276,9 @@ func (c *Client) ExtractFacebookInstantGameID(signedPlayerInfo string, appSecret var payload struct { Algorithm string `json:"algorithm"` - IssuedAt int `json:"issued_at"` PlayerID string `json:"player_id"` RequestPayload string `json:"request_payload"` // discarded + IssuedAt int `json:"issued_at"` } err = json.Unmarshal(payloadRaw, &payload) if err != nil { -- GitLab