blocked users cannot join games
This commit is contained in:
parent
b7c08e681f
commit
a1b45d510b
|
@ -9,6 +9,7 @@ import lila.user.{ User, UserRepo }
|
|||
|
||||
private[lobby] final class Biter(
|
||||
timeline: lila.hub.ActorLazyRef,
|
||||
blocks: (String, String) ⇒ Fu[Boolean],
|
||||
roundMessenger: lila.round.Messenger) {
|
||||
|
||||
def apply(hookId: String, userId: Option[String]): Fu[String ⇒ JoinHook] = for {
|
||||
|
@ -55,8 +56,12 @@ private[lobby] final class Biter(
|
|||
pgnImport = None)
|
||||
|
||||
private def canJoin(hook: Hook, userOption: Option[User]) = hook.open && {
|
||||
hook.realMode.casual || (userOption exists { u ⇒
|
||||
hook.realMode.casual || (userOption ?? { u ⇒
|
||||
hook.realEloRange.fold(true)(_ contains u.elo)
|
||||
})
|
||||
} && !{
|
||||
userOption ?? { u ⇒
|
||||
hook.userId ?? { blocks(_, u.id).await }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ final class Env(
|
|||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
roundMessenger: lila.round.Messenger,
|
||||
blocks: (String, String) ⇒ Fu[Boolean],
|
||||
system: ActorSystem,
|
||||
scheduler: lila.common.Scheduler) {
|
||||
|
||||
|
@ -53,6 +54,7 @@ final class Env(
|
|||
|
||||
private lazy val biter = new Biter(
|
||||
timeline = hub.actor.gameTimeline,
|
||||
blocks = blocks,
|
||||
roundMessenger = roundMessenger)
|
||||
}
|
||||
|
||||
|
@ -63,6 +65,7 @@ object Env {
|
|||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
roundMessenger = lila.round.Env.current.messenger,
|
||||
blocks = lila.relation.Env.current.api.blocks,
|
||||
system = lila.common.PlayApp.system,
|
||||
scheduler = lila.common.PlayApp.scheduler)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ object ApplicationBuild extends Build {
|
|||
)
|
||||
|
||||
lazy val lobby = project("lobby", Seq(
|
||||
common, db, memo, hub, socket, chess, game, user, round, timeline)).settings(
|
||||
common, db, memo, hub, socket, chess, game, user, round, timeline, relation)).settings(
|
||||
libraryDependencies ++= provided(play.api, reactivemongo, playReactivemongo)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue