fix fetching all user IDs by IP
parent
85ec3bf188
commit
6b2fb74095
|
@ -78,6 +78,14 @@ private[security] final class Api(firewall: Firewall, tor: Tor) {
|
|||
_.flatMap(_.getAs[String]("user"))
|
||||
}
|
||||
}
|
||||
|
||||
def userIdsByIp(ip: String): Fu[List[String]] =
|
||||
tube.storeColl.find(
|
||||
BSONDocument("ip" -> ip),
|
||||
BSONDocument("user" -> true)
|
||||
).cursor[BSONDocument]().collect[List]().map {
|
||||
_.flatMap(_.getAs[String]("user"))
|
||||
}.map(_.distinct)
|
||||
}
|
||||
|
||||
object Api {
|
||||
|
|
|
@ -8,7 +8,7 @@ final class Whois(key: String, api: Api, tor: Tor, userJson: lila.user.JsonView)
|
|||
|
||||
def apply(ip: String, reqKey: String): Fu[Either[String, JsObject]] =
|
||||
if (reqKey != key) fuccess(Left("Invalid key"))
|
||||
else api.userIdsSharingIp(ip) flatMap lila.user.UserRepo.byIds map { users =>
|
||||
else api.userIdsByIp(ip) flatMap lila.user.UserRepo.byIds map { users =>
|
||||
Right(Json.obj(
|
||||
"ip" -> ip,
|
||||
"tor" -> tor.isExitNode(ip),
|
||||
|
|
Loading…
Reference in New Issue