diff --git a/server/runtime_go_nakama.go b/server/runtime_go_nakama.go index a0868ffea33438d6d83cefb5ce06ed7b2d1c2029..0b9213a01ec4e76a1149d338cdad56fcfc231105 100644 --- a/server/runtime_go_nakama.go +++ b/server/runtime_go_nakama.go @@ -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 } diff --git a/server/runtime_javascript_nakama.go b/server/runtime_javascript_nakama.go index bb6e67c56b8bda0c341160d616156f564e3db697..8c77cb15acb1d008711217e305e20e3e10f26578 100644 --- a/server/runtime_javascript_nakama.go +++ b/server/runtime_javascript_nakama.go @@ -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()))) } diff --git a/server/runtime_lua_nakama.go b/server/runtime_lua_nakama.go index 26b063cfc38c587c1cff2907e7582c6a39ee7869..ac91b5a3ffbdb71ba7baa7d3f225e95f667d2b6c 100644 --- a/server/runtime_lua_nakama.go +++ b/server/runtime_lua_nakama.go @@ -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