Merge pull request #9916 from benediktwerner/remove-mod-search-method-dropdown
Remove mod search method dropdownpull/9928/head
commit
682dcbfb45
|
@ -396,9 +396,8 @@ final class Mod(
|
|||
}
|
||||
|
||||
protected[controllers] def searchTerm(me: Holder, q: String)(implicit ctx: Context) = {
|
||||
val query = UserSearch exact q
|
||||
env.mod.search(query) map { users =>
|
||||
Ok(html.mod.search(me, UserSearch.form fill query, users))
|
||||
env.mod.search(q) map { users =>
|
||||
Ok(html.mod.search(me, UserSearch.form fill q, users))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,7 +490,7 @@ final class Mod(
|
|||
.map(EmailAddress.apply) flatMap env.security.emailAddressValidator.validate
|
||||
val username = query lift 1
|
||||
def tryWith(setEmail: EmailAddress, q: String): Fu[Option[Result]] =
|
||||
env.mod.search(UserSearch.exact(q)) flatMap {
|
||||
env.mod.search(q) flatMap {
|
||||
case List(UserModel.WithEmails(user, _)) =>
|
||||
(!user.everLoggedIn).?? {
|
||||
lila.mon.user.register.modConfirmEmail.increment()
|
||||
|
|
|
@ -32,10 +32,9 @@ object search {
|
|||
input(
|
||||
name := "q",
|
||||
autofocus,
|
||||
placeholder := "Search by IP, email, or username",
|
||||
placeholder := "Search by IP, email, or username (exact match only)",
|
||||
value := form("q").value
|
||||
),
|
||||
form3.select(form("as"), lila.mod.UserSearch.asChoices)
|
||||
)
|
||||
),
|
||||
userTable(mod, users)
|
||||
)
|
||||
|
|
|
@ -11,13 +11,10 @@ final class UserSearch(
|
|||
userRepo: UserRepo
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
def apply(query: UserSearch.Query): Fu[List[User.WithEmails]] =
|
||||
(~query.as match {
|
||||
case _ => // "exact"
|
||||
EmailAddress.from(query.q).map(searchEmail) orElse
|
||||
IpAddress.from(query.q).map(searchIp) getOrElse
|
||||
searchUsername(query.q)
|
||||
}) flatMap userRepo.withEmailsU
|
||||
def apply(query: String): Fu[List[User.WithEmails]] =
|
||||
EmailAddress.from(query).map(searchEmail) orElse
|
||||
IpAddress.from(query).map(searchIp) getOrElse
|
||||
searchUsername(query) flatMap userRepo.withEmailsU
|
||||
|
||||
private def searchIp(ip: IpAddress) =
|
||||
securityApi recentUserIdsByIp ip map (_.reverse) flatMap userRepo.usersFromSecondary
|
||||
|
@ -34,19 +31,9 @@ final class UserSearch(
|
|||
|
||||
object UserSearch {
|
||||
|
||||
val asChoices = List(
|
||||
"exact" -> "Exact match over all users"
|
||||
)
|
||||
val asValues = asChoices.map(_._1)
|
||||
|
||||
case class Query(q: String, as: Option[String])
|
||||
|
||||
def exact(q: String) = Query(q, none)
|
||||
|
||||
val form = Form(
|
||||
mapping(
|
||||
"q" -> lila.common.Form.trim(nonEmptyText),
|
||||
"as" -> optional(nonEmptyText.verifying(asValues contains _))
|
||||
)(Query.apply)(Query.unapply)
|
||||
single(
|
||||
"q" -> lila.common.Form.trim(nonEmptyText)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue