From 9fadf79b5a73d862edb2c6192c5bf00592a7e98e Mon Sep 17 00:00:00 2001 From: Simon Esposito Date: Wed, 15 Mar 2023 18:53:35 +0000 Subject: [PATCH] Add Go runtime GroupUpdate userID param (#996) --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 +-- server/runtime_go_nakama.go | 16 +++++++-- .../heroiclabs/nakama-common/api/api.proto | 36 +++++++++---------- .../nakama-common/rtapi/realtime.proto | 4 +-- .../nakama-common/runtime/runtime.go | 2 +- vendor/modules.txt | 2 +- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a26910350..70e5ea58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Improve graceful shutdown of Google IAP receipt processor. - If In-App Purchases validation contain mismatching userIDs, do not return an error. - Better handling of matchmaker operations while the interval process is running. +- Add userID param to Go runtime GroupUpdate function. ### Fixed - Consistent validation of override operator in runtime leaderboard record writes. diff --git a/go.mod b/go.mod index 507a36819..0037c34b0 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 - github.com/heroiclabs/nakama-common v1.26.1-0.20230227112928-be92be890386 + github.com/heroiclabs/nakama-common v1.26.1-0.20230315184120-05f3d089030f github.com/jackc/pgconn v1.13.0 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa github.com/jackc/pgtype v1.12.0 diff --git a/go.sum b/go.sum index 581ae12be..b6c8af6cc 100644 --- a/go.sum +++ b/go.sum @@ -285,8 +285,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/heroiclabs/nakama-common v1.26.1-0.20230227112928-be92be890386 h1:fCHcRLOFZDHy3KM+aZQUb/h/8uCfJJSzDKSCkwIRFvs= -github.com/heroiclabs/nakama-common v1.26.1-0.20230227112928-be92be890386/go.mod h1:zdYggBBPmykSfz4zYFJmBDX5wyURSPAGANtJPEDdbx8= +github.com/heroiclabs/nakama-common v1.26.1-0.20230315184120-05f3d089030f h1:FpKuBpmS58yACpsCynhmFuYfuclMDhwA+dZKNFLQe0k= +github.com/heroiclabs/nakama-common v1.26.1-0.20230315184120-05f3d089030f/go.mod h1:zdYggBBPmykSfz4zYFJmBDX5wyURSPAGANtJPEDdbx8= 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_go_nakama.go b/server/runtime_go_nakama.go index ddb19f8c5..88150abf4 100644 --- a/server/runtime_go_nakama.go +++ b/server/runtime_go_nakama.go @@ -3140,7 +3140,7 @@ func (n *RuntimeGoNakamaModule) GroupCreate(ctx context.Context, userID, name, c // @summary Update a group with various configuration settings. The group which is updated can change some or all of its fields. // @param ctx(type=context.Context) The context object represents information about the server and requester. // @param groupId(type=string) The ID of the group to update. -// @param userId(type=string) User ID calling the update operation for permission checking. Set as nil to enact the changes as the system user. +// @param userId(type=string) User ID calling the update operation for permission checking. Set as empty string to enact the changes as the system user. // @param name(type=string) Group name, can be empty if not changed. // @param creatorId(type=string) The user ID to be associated as creator. Can be empty if not changed. // @param langTag(type=string) Group language. Empty if not updated. @@ -3150,12 +3150,22 @@ func (n *RuntimeGoNakamaModule) GroupCreate(ctx context.Context, userID, name, c // @param metadata(type=map[string]interface{}) Custom information to store for this group. Use nil if field is not being updated. // @param maxCount(type=int) Maximum number of members to have in the group. Use 0, nil/null if field is not being updated. // @return error(error) An optional error value if an error occurred. -func (n *RuntimeGoNakamaModule) GroupUpdate(ctx context.Context, id, name, creatorID, langTag, description, avatarUrl string, open bool, metadata map[string]interface{}, maxCount int) error { +func (n *RuntimeGoNakamaModule) GroupUpdate(ctx context.Context, id, userID, name, creatorID, langTag, description, avatarUrl string, open bool, metadata map[string]interface{}, maxCount int) error { groupID, err := uuid.FromString(id) if err != nil { return errors.New("expects group ID to be a valid identifier") } + var uid uuid.UUID + if userID != "" { + uid, err = uuid.FromString(userID) + if err != nil { + return errors.New("expects user ID to be a valid identifier") + } + } else { + uid = uuid.Nil + } + var nameWrapper *wrapperspb.StringValue if name != "" { nameWrapper = &wrapperspb.StringValue{Value: name} @@ -3196,7 +3206,7 @@ func (n *RuntimeGoNakamaModule) GroupUpdate(ctx context.Context, id, name, creat metadataWrapper = &wrapperspb.StringValue{Value: string(metadataBytes)} } - return UpdateGroup(ctx, n.logger, n.db, groupID, uuid.Nil, creator, nameWrapper, langTagWrapper, descriptionWrapper, avatarURLWrapper, metadataWrapper, openWrapper, maxCount) + return UpdateGroup(ctx, n.logger, n.db, groupID, uid, creator, nameWrapper, langTagWrapper, descriptionWrapper, avatarURLWrapper, metadataWrapper, openWrapper, maxCount) } // @group groups diff --git a/vendor/github.com/heroiclabs/nakama-common/api/api.proto b/vendor/github.com/heroiclabs/nakama-common/api/api.proto index 73a281fac..fa99aa4a5 100644 --- a/vendor/github.com/heroiclabs/nakama-common/api/api.proto +++ b/vendor/github.com/heroiclabs/nakama-common/api/api.proto @@ -42,9 +42,9 @@ message Account { repeated AccountDevice devices = 4; // The custom id in the user's account. string custom_id = 5; - // The UNIX time when the user's email was verified. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user's email was verified. google.protobuf.Timestamp verify_time = 6; - // The UNIX time when the user's account was disabled/banned. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user's account was disabled/banned. google.protobuf.Timestamp disable_time = 7; } @@ -298,9 +298,9 @@ message ChannelMessage { string username = 5; // The content payload. string content = 6; - // The UNIX time when the message was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was created. google.protobuf.Timestamp create_time = 7; - // The UNIX time when the message was last updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated. google.protobuf.Timestamp update_time = 8; // True if the message was persisted to the channel's history, false otherwise. google.protobuf.BoolValue persistent = 9; @@ -470,9 +470,9 @@ message Group { int32 edge_count = 9; // The maximum number of members allowed. int32 max_count = 10; - // The UNIX time when the group was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the group was created. google.protobuf.Timestamp create_time = 11; - // The UNIX time when the group was last updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the group was last updated. google.protobuf.Timestamp update_time = 12; } @@ -562,7 +562,7 @@ message Leaderboard { uint32 next_reset = 5; // Additional information stored as a JSON object. string metadata = 6; - // The UNIX time when the leaderboard was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the leaderboard was created. google.protobuf.Timestamp create_time = 7; // Whether the leaderboard was created authoritatively or not. bool authoritative = 8; @@ -592,11 +592,11 @@ message LeaderboardRecord { int32 num_score = 6; // Metadata. string metadata = 7; - // The UNIX time when the leaderboard record was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the leaderboard record was created. google.protobuf.Timestamp create_time = 8; - // The UNIX time when the leaderboard record was updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the leaderboard record was updated. google.protobuf.Timestamp update_time = 9; - // The UNIX time when the leaderboard record expires. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the leaderboard record expires. google.protobuf.Timestamp expiry_time = 10; // The rank of this record. int64 rank = 11; @@ -850,7 +850,7 @@ message Notification { int32 code = 4; // ID of the sender, if a user. Otherwise 'null'. string sender_id = 5; - // The UNIX time when the notification was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the notification was created. google.protobuf.Timestamp create_time = 6; // True if this notification was persisted to the database. bool persistent = 7; @@ -932,9 +932,9 @@ message StorageObject { int32 permission_read = 6; // The write access permissions for the object. int32 permission_write = 7; - // The UNIX time when the object was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the object was created. google.protobuf.Timestamp create_time = 8; - // The UNIX time when the object was last updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the object was last updated. google.protobuf.Timestamp update_time = 9; } @@ -996,11 +996,11 @@ message Tournament { uint32 next_reset = 11; // Additional information stored as a JSON object. string metadata = 12; - // The UNIX time when the tournament was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the tournament was created. google.protobuf.Timestamp create_time = 13; - // The UNIX time when the tournament will start. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the tournament will start. google.protobuf.Timestamp start_time = 14; - // The UNIX time when the tournament will be stopped. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the tournament will be stopped. google.protobuf.Timestamp end_time = 15; // Duration of the tournament in seconds. uint32 duration = 16; @@ -1096,9 +1096,9 @@ message User { bool online = 13; // Number of related edges to this user. int32 edge_count = 14; - // The UNIX time when the user was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user was created. google.protobuf.Timestamp create_time = 15; - // The UNIX time when the user was last updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user was last updated. google.protobuf.Timestamp update_time = 16; // The Facebook Instant Game ID in the user's account. string facebook_instant_game_id = 17; diff --git a/vendor/github.com/heroiclabs/nakama-common/rtapi/realtime.proto b/vendor/github.com/heroiclabs/nakama-common/rtapi/realtime.proto index ef61b4b89..e5fbeb047 100644 --- a/vendor/github.com/heroiclabs/nakama-common/rtapi/realtime.proto +++ b/vendor/github.com/heroiclabs/nakama-common/rtapi/realtime.proto @@ -194,9 +194,9 @@ message ChannelMessageAck { google.protobuf.Int32Value code = 3; // Username of the message sender. string username = 4; - // The UNIX time when the message was created. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was created. google.protobuf.Timestamp create_time = 5; - // The UNIX time when the message was last updated. + // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated. google.protobuf.Timestamp update_time = 6; // True if the message was persisted to the channel's history, false otherwise. google.protobuf.BoolValue persistent = 7; diff --git a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go index fd913a8aa..41e26d634 100644 --- a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go +++ b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go @@ -1102,7 +1102,7 @@ type NakamaModule interface { GroupsGetId(ctx context.Context, groupIDs []string) ([]*api.Group, error) GroupCreate(ctx context.Context, userID, name, creatorID, langTag, description, avatarUrl string, open bool, metadata map[string]interface{}, maxCount int) (*api.Group, error) - GroupUpdate(ctx context.Context, id, name, creatorID, langTag, description, avatarUrl string, open bool, metadata map[string]interface{}, maxCount int) error + GroupUpdate(ctx context.Context, id, userID, name, creatorID, langTag, description, avatarUrl string, open bool, metadata map[string]interface{}, maxCount int) error GroupDelete(ctx context.Context, id string) error GroupUserJoin(ctx context.Context, groupID, userID, username string) error GroupUserLeave(ctx context.Context, groupID, userID, username string) error diff --git a/vendor/modules.txt b/vendor/modules.txt index 49a62aaab..3544b5543 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -143,7 +143,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.26.1-0.20230227112928-be92be890386 +# github.com/heroiclabs/nakama-common v1.26.1-0.20230315184120-05f3d089030f ## explicit; go 1.14 github.com/heroiclabs/nakama-common/api github.com/heroiclabs/nakama-common/rtapi -- GitLab