normalize usernames in crosstable API - fixes #7354

pull/7362/head
Thibault Duplessis 2020-09-24 07:55:01 +02:00
parent 5bb0cf1c89
commit c25df35b77
1 changed files with 3 additions and 1 deletions

View File

@ -175,9 +175,11 @@ final class Api(
key = "crosstable.api.ip"
)
def crosstable(u1: String, u2: String) =
def crosstable(name1: String, name2: String) =
ApiRequest { req =>
CrosstableRateLimitPerIP(HTTPRequest lastRemoteAddress req, cost = 1) {
import lila.user.User.normalize
val (u1, u2) = (normalize(name1), normalize(name2))
env.game.crosstableApi.fetchOrEmpty(u1, u2) flatMap { ct =>
(ct.results.nonEmpty && getBool("matchup", req)).?? {
env.game.crosstableApi.getMatchup(u1, u2)