remove known engines from user api
This commit is contained in:
parent
85624ed3a8
commit
5a6023c245
|
@ -29,7 +29,6 @@ final class Env(
|
|||
getRelay: String => Fu[Option[lila.relay.Relay]],
|
||||
getRelayName: String => Option[String],
|
||||
getTournamentName: String => Option[String],
|
||||
userIdsSharingIp: String => Fu[List[String]],
|
||||
val isProd: Boolean) {
|
||||
|
||||
val CliUsername = config getString "cli.username"
|
||||
|
@ -84,8 +83,7 @@ final class Env(
|
|||
relationApi = relationApi,
|
||||
bookmarkApi = bookmarkApi,
|
||||
crosstableApi = crosstableApi,
|
||||
prefApi = prefApi,
|
||||
userIdsSharingIp = userIdsSharingIp)
|
||||
prefApi = prefApi)
|
||||
|
||||
val analysisApi = new AnalysisApi
|
||||
|
||||
|
@ -144,7 +142,6 @@ object Env {
|
|||
crosstableApi = lila.game.Env.current.crosstableApi,
|
||||
prefApi = lila.pref.Env.current.api,
|
||||
gamePgnDump = lila.game.Env.current.pgnDump,
|
||||
userIdsSharingIp = lila.security.Env.current.api.userIdsSharingIp,
|
||||
system = lila.common.PlayApp.system,
|
||||
isProd = lila.common.PlayApp.isProd)
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ private[api] final class UserApi(
|
|||
crosstableApi: lila.game.CrosstableApi,
|
||||
prefApi: lila.pref.PrefApi,
|
||||
makeUrl: String => String,
|
||||
apiToken: String,
|
||||
userIdsSharingIp: String => Fu[List[String]]) {
|
||||
apiToken: String) {
|
||||
|
||||
def list(
|
||||
team: Option[String],
|
||||
|
@ -45,19 +44,17 @@ private[api] final class UserApi(
|
|||
def one(username: String, token: Option[String])(implicit ctx: Context): Fu[Option[JsObject]] = UserRepo named username flatMap {
|
||||
case None => fuccess(none)
|
||||
case Some(u) => GameRepo mostUrgentGame u zip
|
||||
(check(token) ?? (knownEnginesSharingIp(u.id) map (_.some))) zip
|
||||
(ctx.me.filter(u!=) ?? { me => crosstableApi.nbGames(me.id, u.id) }) zip
|
||||
relationApi.nbFollowing(u.id) zip
|
||||
relationApi.nbFollowers(u.id) zip
|
||||
ctx.isAuth.?? { prefApi followable u.id } zip
|
||||
ctx.userId.?? { relationApi.relation(_, u.id) } zip
|
||||
ctx.userId.?? { relationApi.relation(u.id, _) } map {
|
||||
case (((((((gameOption, knownEngines), nbGamesWithMe), following), followers), followable), relation), revRelation) =>
|
||||
case ((((((gameOption, nbGamesWithMe), following), followers), followable), relation), revRelation) =>
|
||||
jsonView(u, extended = true) ++ {
|
||||
Json.obj(
|
||||
"url" -> makeUrl(s"@/$username"),
|
||||
"playing" -> gameOption.map(g => makeUrl(s"${g.gameId}/{$g.color.name}")),
|
||||
"knownEnginesSharingIp" -> knownEngines,
|
||||
"nbFollowing" -> following,
|
||||
"nbFollowers" -> followers,
|
||||
"count" -> Json.obj(
|
||||
|
@ -82,9 +79,6 @@ private[api] final class UserApi(
|
|||
} map (_.some)
|
||||
}
|
||||
|
||||
def knownEnginesSharingIp(userId: String): Fu[List[String]] =
|
||||
userIdsSharingIp(userId) flatMap UserRepo.filterByEngine
|
||||
|
||||
private def makeNb(nb: Option[Int], token: Option[String]) = math.min(check(token) ? 1000 | 100, nb | 10)
|
||||
|
||||
private def check(token: Option[String]) = token ?? (apiToken==)
|
||||
|
|
Loading…
Reference in a new issue