Unverified Commit d0bb6d5f authored by Simon Esposito's avatar Simon Esposito Committed by GitHub
Browse files

Add senderID to ChannelIdBuild (#790)

parent e27f397c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Improve Stackdriver log format timestamp and message field formats.
- Use crypto random to seed global random instance if possible.
- Allow migrate subcommand to use database names that contain dashes.
- Add senderID param to channelIdBuild function.

### Fixed
- Fix the registered function name for 'nk.channelIdBuild' in the JavaScript runtime.
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ version: '3'
services:
  postgres:
    container_name: postgres
    image: postgres:9.6-alpine
    image: postgres:12.2-alpine
    environment:
      - POSTGRES_DB=nakama
      - POSTGRES_PASSWORD=localdb
+1 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ require (
	github.com/gorilla/mux v1.8.0
	github.com/gorilla/websocket v1.4.2
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
	github.com/heroiclabs/nakama-common v1.21.1-0.20220117102903-bc0471af4fe1
	github.com/heroiclabs/nakama-common v1.21.1-0.20220225112712-3adfceaba805
	github.com/jackc/pgconn v1.10.0
	github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451
	github.com/jackc/pgtype v1.8.1
@@ -76,5 +76,3 @@ require (
	gopkg.in/gorp.v1 v1.7.2 // indirect
	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/heroiclabe/nakama-common => ../nakama-common
+2 −0
Original line number Diff line number Diff line
@@ -257,6 +257,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/heroiclabs/nakama-common v1.21.1-0.20220117102903-bc0471af4fe1 h1:x/dBIoeLjzb8PnCbrOsVEda8AJy+kmWj/zRTVkO9mc8=
github.com/heroiclabs/nakama-common v1.21.1-0.20220117102903-bc0471af4fe1/go.mod h1:WF4YG46afwY3ibzsXnkt3zvhQ3tBY03IYeU7xSLr8HE=
github.com/heroiclabs/nakama-common v1.21.1-0.20220225112712-3adfceaba805 h1:GxmEr5fxdNEamOJmCPeUYdJvMQsJJJNZnBnkBmJxG9M=
github.com/heroiclabs/nakama-common v1.21.1-0.20220225112712-3adfceaba805/go.mod h1:WF4YG46afwY3ibzsXnkt3zvhQ3tBY03IYeU7xSLr8HE=
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=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
+12 −2
Original line number Diff line number Diff line
@@ -3456,12 +3456,22 @@ func (n *RuntimeGoNakamaModule) ChannelMessageUpdate(ctx context.Context, channe
// @group chat
// @summary Create a channel identifier to be used in other runtime calls. Does not create a channel.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @param senderId(type=string) UserID of the message sender (when applicable). An empty string defaults to the system user.
// @param target(type=string) Can be the room name, group identifier, or another username.
// @param chanType(type=runtime.ChannelType) The type of channel, for example group or direct.
// @return channelId(string) The generated ID representing a channel.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) ChannelIdBuild(ctx context.Context, target string, chanType runtime.ChannelType) (string, error) {
	channelId, _, err := BuildChannelId(ctx, n.logger, n.db, uuid.Nil, target, rtapi.ChannelJoin_Type(chanType))
func (n *RuntimeGoNakamaModule) ChannelIdBuild(ctx context.Context, senderId, target string, chanType runtime.ChannelType) (string, error) {
	senderUUID := uuid.Nil
	if senderId != "" {
		var err error
		senderUUID, err = uuid.FromString(senderId)
		if err != nil {
			return "", err
		}
	}

	channelId, _, err := BuildChannelId(ctx, n.logger, n.db, senderUUID, target, rtapi.ChannelJoin_Type(chanType))
	if err != nil {
		return "", err
	}
Loading