Commit cf654a65 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Ensure default parameters for tournament listings are consistent between API and runtimes.

parent f01c89a9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Handle Google IAP validation token caching when using credential overrides.
- More graceful handling of no-op authoritative storage delete operations.
- Ensure rank cache is correctly updated when joining tournaments.
- Ensure default parameters for tournament listings are consistent between API and runtimes.

## [3.14.0] - 2022-10-14
### Added
+2 −2
Original line number Diff line number Diff line
@@ -214,12 +214,12 @@ func (s *ApiServer) ListTournaments(ctx context.Context, in *api.ListTournaments
	}

	// If startTime and endTime are both not set the API will only return active or future tournaments.
	startTime := -1 // don't include start time in query
	startTime := -1 // Don't include start time in query by default.
	if in.GetStartTime() != nil {
		startTime = int(in.GetStartTime().GetValue())
	}

	endTime := -1 // don't include end time in query
	endTime := -1 // Don't include end time in query by default.
	if in.GetEndTime() != nil {
		endTime = int(in.GetEndTime().GetValue())
		if endTime != 0 && endTime < startTime { // Allow 0 value to explicitly request tournaments with no end time set.
+2 −2
Original line number Diff line number Diff line
@@ -6182,7 +6182,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentList(r *goja.Runtime) func(goj
			panic(r.NewTypeError("category end must be >= category start"))
		}

		startTime := 0
		startTime := -1
		if f.Argument(2) != goja.Undefined() && f.Argument(2) != goja.Null() {
			startTime = int(getJsInt(r, f.Argument(2)))
			if startTime < 0 {
@@ -6190,7 +6190,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentList(r *goja.Runtime) func(goj
			}
		}

		endTime := 0
		endTime := -1
		if f.Argument(3) != goja.Undefined() && f.Argument(3) != goja.Null() {
			endTime = int(getJsInt(r, f.Argument(3)))
			if endTime < 0 {
+23 −8
Original line number Diff line number Diff line
@@ -7720,16 +7720,31 @@ func (n *RuntimeLuaNakamaModule) tournamentList(l *lua.LState) int {
		l.ArgError(2, "categoryEnd must be >= categoryStart")
		return 0
	}
	startTime := l.OptInt(3, 0)

	startTime := -1
	if v := l.Get(3); v.Type() != lua.LTNil {
		if v.Type() != lua.LTNumber {
			l.ArgError(3, "startTime must be >= 0")
			return 0
		}
		startTime = int(lua.LVAsNumber(v))
		if startTime < 0 {
			l.ArgError(3, "startTime must be >= 0")
			return 0
		}
	endTime := l.OptInt(4, 0)
	}
	endTime := -1
	if v := l.Get(4); v.Type() != lua.LTNil {
		if v.Type() != lua.LTNumber {
			l.ArgError(4, "endTime must be >= 0")
			return 0
		}
		endTime = int(lua.LVAsNumber(v))
		if endTime < 0 {
			l.ArgError(4, "endTime must be >= 0")
			return 0
		}
	}
	if startTime > endTime {
		l.ArgError(4, "endTime must be >= startTime")
		return 0