hide blocking and blockers hooks
parent
4b10b099ce
commit
8b3abe650f
|
@ -21,6 +21,7 @@ final class Env(
|
|||
lobby = Env.lobby.lobby,
|
||||
history = Env.lobby.history,
|
||||
featured = Env.game.featured,
|
||||
relations = Env.relation.api,
|
||||
recentGames = () ⇒ Env.timeline.getter.recentGames,
|
||||
timelineEntries = Env.timeline.getter.userEntries _)
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@ import lila.socket.History
|
|||
import lila.timeline.{ Entry, GameEntry }
|
||||
import lila.tournament.Created
|
||||
import lila.user.{ User, Context }
|
||||
import lila.relation.RelationApi
|
||||
import makeTimeout.large
|
||||
|
||||
final class Preload(
|
||||
lobby: ActorRef,
|
||||
history: History,
|
||||
featured: Featured,
|
||||
relations: RelationApi,
|
||||
recentGames: () ⇒ Fu[List[GameEntry]],
|
||||
timelineEntries: String ⇒ Fu[List[Entry]]) {
|
||||
|
||||
|
@ -37,13 +39,15 @@ final class Preload(
|
|||
posts zip
|
||||
tours zip
|
||||
featured.one zip
|
||||
(ctx.userId ?? relations.blocks) zip
|
||||
(ctx.userId ?? timelineEntries) zip
|
||||
filter map {
|
||||
case ((((((hooks, gameEntries), posts), tours), feat), entries), filter) ⇒
|
||||
case (((((((hooks, gameEntries), posts), tours), feat), blocks), entries), filter) ⇒
|
||||
(Right((Json.obj(
|
||||
"version" -> history.version,
|
||||
"pool" -> JsArray(hooks map (_.render)),
|
||||
"filter" -> filter.render
|
||||
"filter" -> filter.render,
|
||||
"blocks" -> blocks
|
||||
), entries, gameEntries, posts, tours, feat)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ final class RelationApi(
|
|||
def blockers(userId: ID) = cached blockers userId
|
||||
def blocking(userId: ID) = cached blocking userId
|
||||
|
||||
def blocks(userId: ID) = blockers(userId) ⊹ blocking(userId)
|
||||
|
||||
def nbFollowers(userId: ID) = followers(userId) map (_.size)
|
||||
def nbFollowing(userId: ID) = following(userId) map (_.size)
|
||||
def nbBlockers(userId: ID) = blockers(userId) map (_.size)
|
||||
|
|
|
@ -49,6 +49,8 @@ case class User(
|
|||
|
||||
object User {
|
||||
|
||||
type ID = String
|
||||
|
||||
val STARTING_ELO = 1200
|
||||
|
||||
val anonymous = "Anonymous"
|
||||
|
@ -80,5 +82,5 @@ object User {
|
|||
"toints" -> 0,
|
||||
"roles" -> Json.arr(),
|
||||
"seenAt" -> none[DateTime],
|
||||
"lang" -> none[String] )
|
||||
"lang" -> none[String])
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package lila.user
|
||||
|
||||
import com.roundeights.hasher.Implicits._
|
||||
import lila.common.PimpedJson._
|
||||
import lila.db.api._
|
||||
import lila.db.Implicits._
|
||||
import org.joda.time.DateTime
|
||||
import ornicar.scalalib.Random
|
||||
import play.api.libs.json._
|
||||
import play.modules.reactivemongo.json.BSONFormats.toJSON
|
||||
import play.modules.reactivemongo.json.ImplicitBSONHandlers.JsObjectWriter
|
||||
import reactivemongo.api._
|
||||
|
||||
import lila.common.PimpedJson._
|
||||
import lila.db.api._
|
||||
import lila.db.Implicits._
|
||||
import tube.userTube
|
||||
|
||||
object UserRepo {
|
||||
|
||||
type ID = String
|
||||
import User.ID
|
||||
|
||||
val normalize = User normalize _
|
||||
|
||||
|
@ -26,10 +27,10 @@ object UserRepo {
|
|||
def topBlitz = topSpeed("blitz") _
|
||||
def topSlow = topSpeed("slow") _
|
||||
|
||||
def topSpeed(speed: String)(nb: Int): Fu[List[User]] =
|
||||
def topSpeed(speed: String)(nb: Int): Fu[List[User]] =
|
||||
$find(goodLadQuery sort ($sort desc "speedElos." + speed + ".elo"), nb)
|
||||
|
||||
def topNbGame(nb: Int): Fu[List[User]] =
|
||||
def topNbGame(nb: Int): Fu[List[User]] =
|
||||
$find(goodLadQuery sort ($sort desc "count.game"), nb)
|
||||
|
||||
def byId(id: ID): Fu[Option[User]] = $find byId id
|
||||
|
|
|
@ -32,7 +32,7 @@ object Dependencies {
|
|||
}
|
||||
|
||||
val scalaz = "org.scalaz" %% "scalaz-core" % "7.0.3"
|
||||
val scalalib = "com.github.ornicar" %% "scalalib" % "4.18"
|
||||
val scalalib = "com.github.ornicar" %% "scalalib" % "4.19"
|
||||
val config = "com.typesafe" % "config" % "1.0.2"
|
||||
val apache = "org.apache.commons" % "commons-lang3" % "3.1"
|
||||
val scalaTime = "org.scala-tools.time" % "time_2.9.1" % "0.5"
|
||||
|
|
|
@ -2204,6 +2204,7 @@ var storage = {
|
|||
|
||||
function addHook(hook, inBatch) {
|
||||
if (!isRegistered && hook.mode == "Casual" && !hook.allowAnon) return;
|
||||
if (_.contains(lichess_preload.blocks, hook.username.toLowerCase())) return;
|
||||
if (!isRegistered && hook.mode == "Rated") hook.action = 'register';
|
||||
else hook.action = hook.uid == lichess_sri ? "cancel" : "join";
|
||||
if (hook.action == 'join' && hook.emin && myElo && (myElo < parseInt(hook.emin) || myElo > parseInt(hook.emax))) return;
|
||||
|
|
Loading…
Reference in New Issue