show swiss chats instead of self-moderated simul chats in mod view
parent
65cb30452e
commit
913fa06d86
|
@ -59,8 +59,8 @@ final class Mod(
|
|||
|
||||
def publicChat =
|
||||
Secure(_.PublicChatView) { implicit ctx => _ =>
|
||||
env.mod.publicChat.all map { case (tournamentsAndChats, simulsAndChats) =>
|
||||
Ok(html.mod.publicChat(tournamentsAndChats, simulsAndChats))
|
||||
env.mod.publicChat.all map { case (tournamentsAndChats, swissesAndChats) =>
|
||||
Ok(html.mod.publicChat(tournamentsAndChats, swissesAndChats))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ object publicChat {
|
|||
|
||||
def apply(
|
||||
tourChats: List[(lila.tournament.Tournament, UserChat)],
|
||||
simulChats: List[(lila.simul.Simul, UserChat)]
|
||||
swissChats: List[(lila.swiss.Swiss, UserChat)]
|
||||
)(implicit ctx: Context) =
|
||||
views.html.base.layout(
|
||||
title = "Public Chats",
|
||||
|
@ -33,11 +33,11 @@ object publicChat {
|
|||
}
|
||||
),
|
||||
div(
|
||||
h2("Simul Chats"),
|
||||
h2("Swiss Chats"),
|
||||
div(cls := "player_chats")(
|
||||
simulChats.map { case (simul, chat) =>
|
||||
div(cls := "game", dataChan := "simul", dataRoom := simul.id)(
|
||||
chatOf(routes.Simul.show(simul.id), simul.name, chat)
|
||||
swissChats.map { case (swiss, chat) =>
|
||||
div(cls := "game", dataChan := "swiss", dataRoom := swiss.id.value)(
|
||||
chatOf(routes.Swiss.show(swiss.id.value), swiss.name, chat)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -181,7 +181,7 @@ lazy val event = module("event",
|
|||
)
|
||||
|
||||
lazy val mod = module("mod",
|
||||
Seq(common, db, user, hub, security, tournament, simul, game, analyse, evaluation, report, notifyModule, history, perfStat, irc),
|
||||
Seq(common, db, user, hub, security, tournament, swiss, game, analyse, evaluation, report, notifyModule, history, perfStat, irc),
|
||||
reactivemongo.bundle
|
||||
)
|
||||
|
||||
|
@ -226,7 +226,7 @@ lazy val pool = module("pool",
|
|||
)
|
||||
|
||||
lazy val activity = module("activity",
|
||||
Seq(common, game, analyse, user, forum, study, pool, puzzle, tournament, swiss, practice, team, ublog),
|
||||
Seq(common, game, analyse, user, forum, study, pool, puzzle, tournament, simul, swiss, practice, team, ublog),
|
||||
reactivemongo.bundle
|
||||
)
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ final class Env(
|
|||
lightUserApi: lila.user.LightUserApi,
|
||||
securityApi: lila.security.SecurityApi,
|
||||
tournamentApi: lila.tournament.TournamentApi,
|
||||
swissFeature: lila.swiss.SwissFeature,
|
||||
gameRepo: lila.game.GameRepo,
|
||||
analysisRepo: lila.analyse.AnalysisRepo,
|
||||
userRepo: lila.user.UserRepo,
|
||||
simulEnv: lila.simul.Env,
|
||||
chatApi: lila.chat.ChatApi,
|
||||
notifyApi: lila.notify.NotifyApi,
|
||||
historyApi: lila.history.HistoryApi,
|
||||
|
|
|
@ -2,19 +2,19 @@ package lila.mod
|
|||
|
||||
import lila.chat.{ Chat, UserChat }
|
||||
import lila.report.Suspect
|
||||
import lila.simul.Simul
|
||||
import lila.swiss.Swiss
|
||||
import lila.tournament.Tournament
|
||||
import lila.user.{ User, UserRepo }
|
||||
|
||||
final class PublicChat(
|
||||
chatApi: lila.chat.ChatApi,
|
||||
tournamentApi: lila.tournament.TournamentApi,
|
||||
simulEnv: lila.simul.Env,
|
||||
swissFeature: lila.swiss.SwissFeature,
|
||||
userRepo: UserRepo
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
def all: Fu[(List[(Tournament, UserChat)], List[(Simul, UserChat)])] =
|
||||
tournamentChats zip simulChats
|
||||
def all: Fu[(List[(Tournament, UserChat)], List[(Swiss, UserChat)])] =
|
||||
tournamentChats zip swissChats
|
||||
|
||||
def deleteAll(userId: User.ID): Funit =
|
||||
userRepo byId userId map2 Suspect flatMap { _ ?? deleteAll }
|
||||
|
@ -30,32 +30,25 @@ final class PublicChat(
|
|||
|
||||
private def tournamentChats: Fu[List[(Tournament, UserChat)]] =
|
||||
tournamentApi.fetchVisibleTournaments.flatMap { visibleTournaments =>
|
||||
val ids = visibleTournaments.all.map(_.id) map Chat.Id.apply
|
||||
val ids = visibleTournaments.all.map(_.id) map Chat.Id
|
||||
chatApi.userChat.findAll(ids).map { chats =>
|
||||
chats.flatMap { chat =>
|
||||
visibleTournaments.all.find(_.id == chat.id.value).map(tour => (tour, chat))
|
||||
visibleTournaments.all.find(_.id == chat.id.value).map(_ -> chat)
|
||||
}
|
||||
} map sortTournamentsByRelevance
|
||||
}
|
||||
|
||||
private def simulChats: Fu[List[(Simul, UserChat)]] =
|
||||
fetchVisibleSimuls.flatMap { simuls =>
|
||||
val ids = simuls.map(_.id) map Chat.Id.apply
|
||||
private def swissChats: Fu[List[(Swiss, UserChat)]] =
|
||||
swissFeature.get(Nil).flatMap { swisses =>
|
||||
val all = swisses.created ::: swisses.started
|
||||
val ids = all.map(_.id.value) map Chat.Id
|
||||
chatApi.userChat.findAll(ids).map { chats =>
|
||||
chats.flatMap { chat =>
|
||||
simuls.find(_.id == chat.id.value).map(simul => (simul, chat))
|
||||
all.find(_.id.value == chat.id.value).map(_ -> chat)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private def fetchVisibleSimuls: Fu[List[Simul]] = {
|
||||
simulEnv.allCreatedFeaturable.get {} zip
|
||||
simulEnv.repo.allStarted zip
|
||||
simulEnv.repo.allFinishedFeaturable(3) map { case ((created, started), finished) =>
|
||||
created ::: started ::: finished
|
||||
}
|
||||
}
|
||||
|
||||
/** Sort the tournaments by the tournaments most likely to require moderation attention
|
||||
*/
|
||||
private def sortTournamentsByRelevance(tournaments: List[(Tournament, UserChat)]) =
|
||||
|
|
Loading…
Reference in New Issue