From b67c42b863bcee0da5865017a8d3737b09089eac Mon Sep 17 00:00:00 2001 From: John Cowan <76956944+r22222@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:24:37 -0500 Subject: [PATCH 1/2] Ensure flagged users do not appear on TV --- modules/db/src/main/Env.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/db/src/main/Env.scala b/modules/db/src/main/Env.scala index edc052781989a..01cdd0410462c 100644 --- a/modules/db/src/main/Env.scala +++ b/modules/db/src/main/Env.scala @@ -6,6 +6,8 @@ import com.softwaremill.tagging.* import com.typesafe.config.Config import play.api.Configuration import reactivemongo.api.* +import lila.core.LightUser.GetterSync +import lila.core.user.UserApi import lila.common.Lilakka @@ -15,7 +17,9 @@ trait YoloDb @Module final class Env( appConfig: Configuration, - shutdown: CoordinatedShutdown + shutdown: CoordinatedShutdown, + lightUserSync: GetterSync, + userApi: UserApi )(using Executor): private val driver = new AsyncDriver(appConfig.get[Config]("mongodb").some) From 324d225e4dfc730bfdce6e57f566ea58c8cdfb5e Mon Sep 17 00:00:00 2001 From: John Cowan <76956944+r22222@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:41:57 -0500 Subject: [PATCH 2/2] Ensure flagged users do not appear on TV - added TvSyncActor.scala changes --- modules/tv/src/main/TvSyncActor.scala | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/tv/src/main/TvSyncActor.scala b/modules/tv/src/main/TvSyncActor.scala index 6b87b8d9fbbf1..2b1cab92dc46b 100644 --- a/modules/tv/src/main/TvSyncActor.scala +++ b/modules/tv/src/main/TvSyncActor.scala @@ -5,9 +5,11 @@ import play.api.libs.json.Json import lila.common.Bus import lila.common.Json.given +import lila.core.user.UserApi final private[tv] class TvSyncActor( lightUserApi: lila.core.user.LightUserApi, + userApi: UserApi, onTvGame: lila.game.core.OnTvGame, gameProxy: lila.core.game.GameProxy, rematches: lila.game.Rematches @@ -51,12 +53,17 @@ final private[tv] class TvSyncActor( case lila.core.game.StartGame(g) => if g.hasClock then - val candidate = Tv.Candidate(g, g.userIds.exists(lightUserApi.isBotSync)) - channelActors - .collect { - case (chan, actor) if chan.filter(candidate) => actor - } - .foreach(_.addCandidate(g)) + userApi + .countEngines(g.userIds) + .map(nb => + if nb == 0 then + val candidate = Tv.Candidate(g, g.userIds.exists(lightUserApi.isBotSync)) + channelActors + .collect { + case (chan, actor) if chan.filter(candidate) => actor + } + .foreach(_.addCandidate(g)) + ) case s @ TvSyncActor.Select => channelActors.foreach(_._2 ! s)