Skip to content

Commit

Permalink
tweak bulk limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jan 23, 2024
1 parent 843ad5b commit 8af2e71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
10 changes: 6 additions & 4 deletions app/controllers/OAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ final class OAuth(env: Env, apiC: => Api) extends LilaController(env):

def challengeTokens = ScopedBody(_.Web.Mod) { ctx ?=> me ?=>
if isGranted(_.ApiChallengeAdmin) then
lila.oauth.OAuthTokenForm.adminChallengeTokens
lila.oauth.OAuthTokenForm
.adminChallengeTokens()
.bindFromRequest()
.fold(
jsonFormError,
data =>
env.oAuth.tokenApi.adminChallengeTokens(data, me).map { tokens =>
JsonOk(tokens.view.mapValues(_.plain).toMap)
}
env.oAuth.tokenApi
.adminChallengeTokens(data, me)
.map: tokens =>
JsonOk(tokens.view.mapValues(_.plain).toMap)
)
else Unauthorized(jsonError("Missing permission"))
}
Expand Down
5 changes: 1 addition & 4 deletions modules/game/src/main/GamesByUsersStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import lila.common.Bus
import lila.common.Json.given
import lila.db.dsl.given

final class GamesByUsersStream(gameRepo: lila.game.GameRepo)(using
mat: akka.stream.Materializer,
ec: Executor
):
final class GamesByUsersStream(gameRepo: lila.game.GameRepo)(using akka.stream.Materializer, Executor):

private val chans = List("startGame", "finishGame")

Expand Down
4 changes: 2 additions & 2 deletions modules/oauth/src/main/OAuthTokenForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ object OAuthTokenForm:

case class Data(description: String, scopes: List[String])

def adminChallengeTokens = Form(
def adminChallengeTokens(max: Int = 1000) = Form(
mapping(
"description" -> descriptionField,
"users" -> cleanText
.verifying("No more than 500 users", _.split(',').size <= 500)
.verifying(s"No more than $max users", _.split(',').size <= max)
)(AdminChallengeTokensData.apply)(unapply)
)

Expand Down
2 changes: 1 addition & 1 deletion modules/setup/src/main/SetupBulk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object SetupBulk:
mapping(
"players" -> nonEmptyText
.verifying("Not enough tokens", t => extractTokenPairs(t).nonEmpty)
.verifying(s"Too many tokens (max: ${maxGames * 2})", t => extractTokenPairs(t).sizeIs < maxGames),
.verifying(s"Too many tokens (max: ${maxGames * 2})", t => extractTokenPairs(t).sizeIs <= maxGames),
SetupForm.api.variant,
SetupForm.api.clock,
SetupForm.api.optionalDays,
Expand Down

0 comments on commit 8af2e71

Please sign in to comment.