Commit 7e107807 authored by Fernando Takagi's avatar Fernando Takagi
Browse files

Add to runtime definitions

parent ece43904
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -3907,11 +3907,12 @@ func (n *RuntimeGoNakamaModule) ChannelMessageRemove(ctx context.Context, channe
// @param limit(type=int) The number of messages to return per page.
// @param forward(type=bool) Whether to list messages from oldest to newest, or newest to oldest.
// @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning.
// @param instant(type=int64, optional=true, default=0) Time which around to list messages, since epoch in seconds. Used only if no cursor is provided.
// @return channelMessageList([]*rtapi.ChannelMessage) Messages from the specified channel.
// @return nextCursor(string) Cursor for the next page of messages, if any.
// @return prevCursor(string) Cursor for the previous page of messages, if any.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeGoNakamaModule) ChannelMessagesList(ctx context.Context, channelId string, limit int, forward bool, cursor string) ([]*api.ChannelMessage, string, string, error) {
func (n *RuntimeGoNakamaModule) ChannelMessagesList(ctx context.Context, channelId string, limit int, forward bool, cursor string, instant int64) ([]*api.ChannelMessage, string, string, error) {
	channelIdToStreamResult, err := ChannelIdToStream(channelId)
	if err != nil {
		return nil, "", "", err
@@ -3921,7 +3922,7 @@ func (n *RuntimeGoNakamaModule) ChannelMessagesList(ctx context.Context, channel
		return nil, "", "", errors.New("limit must be 1-100")
	}

	list, err := ChannelMessagesList(ctx, n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, nil)
	list, err := ChannelMessagesList(ctx, n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, instant)
	if err != nil {
		return nil, "", "", err
	}
+7 −1
Original line number Diff line number Diff line
@@ -7979,6 +7979,7 @@ func (n *runtimeJavascriptNakamaModule) channelMessageRemove(r *goja.Runtime) fu
// @param limit(type=number, optional=true, default=100) The number of messages to return per page.
// @param forward(type=bool, optional=true, default=true) Whether to list messages from oldest to newest, or newest to oldest.
// @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning.
// @param instant(type=number, optional=true, default=0) Time which around to list messages, since epoch in seconds. Used only if no cursor is provided.
// @return channelMessagesList(nkruntime.ChannelMessageList) Messages from the specified channel and possibly a cursor. If cursor is empty/null there are no further results.
// @return error(error) An optional error value if an error occurred.
func (n *runtimeJavascriptNakamaModule) channelMessagesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value {
@@ -8003,12 +8004,17 @@ func (n *runtimeJavascriptNakamaModule) channelMessagesList(r *goja.Runtime) fun
			cursor = getJsString(r, f.Argument(3))
		}

		var haystackTime int64
		if f.Argument(4) != goja.Undefined() && f.Argument(4) != goja.Null() {
			haystackTime = getJsInt(r, f.Argument(4))
		}

		channelIdToStreamResult, err := ChannelIdToStream(channelId)
		if err != nil {
			panic(r.NewTypeError(err.Error()))
		}

		list, err := ChannelMessagesList(n.ctx, n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, nil)
		list, err := ChannelMessagesList(n.ctx, n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, haystackTime)
		if err != nil {
			panic(r.NewGoError(fmt.Errorf("failed to list channel messages: %s", err.Error())))
		}
+4 −1
Original line number Diff line number Diff line
@@ -9545,6 +9545,7 @@ func (n *RuntimeLuaNakamaModule) channelMessageRemove(l *lua.LState) int {
// @param limit(type=number, optional=true, default=100) The number of messages to return per page.
// @param forward(type=bool, optional=true, default=true) Whether to list messages from oldest to newest, or newest to oldest.
// @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning.
// @param instant(type=number, optional=true, default=0) Time which around to list messages, since epoch in seconds. Used only if no cursor is provided.
// @return messages(table) Messages from the specified channel.
// @return nextCursor(string) Cursor for the next page of messages, if any. Will be set to "" or nil when fetching last available page.
// @return prevCursor(string) Cursor for the previous page of messages, if any.
@@ -9561,13 +9562,15 @@ func (n *RuntimeLuaNakamaModule) channelMessagesList(l *lua.LState) int {

	cursor := l.OptString(4, "")

	haystackTime := l.OptInt64(5, 0)

	channelIdToStreamResult, err := ChannelIdToStream(channelId)
	if err != nil {
		l.RaiseError(err.Error())
		return 0
	}

	list, err := ChannelMessagesList(l.Context(), n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, nil)
	list, err := ChannelMessagesList(l.Context(), n.logger, n.db, uuid.Nil, channelIdToStreamResult.Stream, channelId, limit, forward, cursor, haystackTime)
	if err != nil {
		l.RaiseError("failed to list channel messages: %v", err.Error())
		return 0