commit
6c6a848fd1
|
@ -58,7 +58,7 @@ final class Mod(
|
|||
)
|
||||
|
||||
def publicChat =
|
||||
Secure(_.ChatTimeout) { implicit ctx => _ =>
|
||||
Secure(_.PublicChatView) { implicit ctx => _ =>
|
||||
env.mod.publicChat.all map { case (tournamentsAndChats, simulsAndChats) =>
|
||||
Ok(html.mod.publicChat(tournamentsAndChats, simulsAndChats))
|
||||
}
|
||||
|
@ -323,14 +323,14 @@ final class Mod(
|
|||
}
|
||||
|
||||
def gamify =
|
||||
Secure(_.SeeReport) { implicit ctx => _ =>
|
||||
Secure(_.GamifyView) { implicit ctx => _ =>
|
||||
env.mod.gamify.leaderboards zip
|
||||
env.mod.gamify.history(orCompute = true) map { case (leaderboards, history) =>
|
||||
Ok(html.mod.gamify.index(leaderboards, history))
|
||||
}
|
||||
}
|
||||
def gamifyPeriod(periodStr: String) =
|
||||
Secure(_.SeeReport) { implicit ctx => _ =>
|
||||
Secure(_.GamifyView) { implicit ctx => _ =>
|
||||
lila.mod.Gamify.Period(periodStr).fold(notFound) { period =>
|
||||
env.mod.gamify.leaderboards map { leaderboards =>
|
||||
Ok(html.mod.gamify.period(leaderboards, period))
|
||||
|
|
|
@ -310,7 +310,7 @@ object layout {
|
|||
)
|
||||
|
||||
private def reports(implicit ctx: Context) =
|
||||
isGranted(_.SeeReport) option {
|
||||
if (isGranted(_.SeeReport)) {
|
||||
blockingReportScores match {
|
||||
case (score, mid, high) =>
|
||||
a(
|
||||
|
@ -325,7 +325,15 @@ object layout {
|
|||
dataIcon := ""
|
||||
)
|
||||
}
|
||||
}
|
||||
}.some
|
||||
else
|
||||
(isGranted(_.PublicChatView)) option
|
||||
a(
|
||||
cls := "link",
|
||||
title := "Moderation",
|
||||
href := routes.Mod.publicChat,
|
||||
dataIcon := ""
|
||||
)
|
||||
|
||||
private def teamRequests(implicit ctx: Context) =
|
||||
ctx.teamNbRequests > 0 option
|
||||
|
|
|
@ -12,9 +12,9 @@ object menu {
|
|||
st.nav(cls := "page-menu__menu subnav")(
|
||||
isGranted(_.SeeReport) option
|
||||
a(cls := active.active("report"), href := routes.Report.list)("Reports"),
|
||||
isGranted(_.ChatTimeout) option
|
||||
isGranted(_.PublicChatView) option
|
||||
a(cls := active.active("public-chat"), href := routes.Mod.publicChat)("Public Chats"),
|
||||
isGranted(_.SeeReport) option
|
||||
isGranted(_.GamifyView) option
|
||||
a(cls := active.active("gamify"), href := routes.Mod.gamify)("Hall of fame"),
|
||||
isGranted(_.UserSearch) option
|
||||
a(cls := active.active("search"), href := routes.Mod.search)("Search users"),
|
||||
|
|
|
@ -14,6 +14,7 @@ import lila.user.User
|
|||
final class Gamify(
|
||||
logRepo: ModlogRepo,
|
||||
reportApi: lila.report.ReportApi,
|
||||
modApi: lila.mod.ModApi,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
historyRepo: HistoryRepo
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
@ -85,22 +86,24 @@ final class Gamify(
|
|||
}
|
||||
|
||||
private def mixedLeaderboard(after: DateTime, before: Option[DateTime]): Fu[List[ModMixed]] =
|
||||
actionLeaderboard(after, before) zip reportLeaderboard(after, before) map { case (actions, reports) =>
|
||||
actions.map(_.modId) intersect reports.map(_.modId) map { modId =>
|
||||
ModMixed(
|
||||
modId,
|
||||
action = actions.find(_.modId == modId) ?? (_.count),
|
||||
report = reports.find(_.modId == modId) ?? (_.count)
|
||||
)
|
||||
} sortBy (-_.score)
|
||||
}
|
||||
for {
|
||||
actions <- actionLeaderboard(after, before)
|
||||
reports <- reportLeaderboard(after, before)
|
||||
modList <- modApi.allMods
|
||||
} yield actions.map(_.modId) intersect modList.map(_.id) diff hidden map { modId =>
|
||||
ModMixed(
|
||||
modId,
|
||||
action = actions.find(_.modId == modId) ?? (_.count),
|
||||
report = reports.find(_.modId == modId) ?? (_.count)
|
||||
)
|
||||
} sortBy (-_.score)
|
||||
|
||||
private def dateRange(from: DateTime, toOption: Option[DateTime]) =
|
||||
$doc("$gte" -> from) ++ toOption.?? { to =>
|
||||
$doc("$lt" -> to)
|
||||
}
|
||||
|
||||
private val notHidden = $nin(User.lichessId, "slanchevbyarg")
|
||||
private val hidden = List(User.lichessId, "irwin")
|
||||
|
||||
private def actionLeaderboard(after: DateTime, before: Option[DateTime]): Fu[List[ModCount]] =
|
||||
logRepo.coll
|
||||
|
@ -109,7 +112,7 @@ final class Gamify(
|
|||
Match(
|
||||
$doc(
|
||||
"date" -> dateRange(after, before),
|
||||
"mod" -> notHidden
|
||||
"mod" -> $nin(hidden)
|
||||
)
|
||||
) -> List(
|
||||
GroupField("mod")("nb" -> SumAll),
|
||||
|
@ -134,7 +137,7 @@ final class Gamify(
|
|||
$doc(
|
||||
"atoms.0.at" -> dateRange(after, before),
|
||||
"room" $in Room.all, // required to make use of the mongodb index room+atoms.0.at
|
||||
"processedBy" -> notHidden
|
||||
"processedBy" -> $nin(hidden)
|
||||
)
|
||||
) -> List(
|
||||
GroupField("processedBy")(
|
||||
|
|
|
@ -17,6 +17,8 @@ object Permission {
|
|||
case object ModerateForum extends Permission("MODERATE_FORUM", "Moderate forum")
|
||||
|
||||
case object ChatTimeout extends Permission("CHAT_TIMEOUT", "Chat timeout")
|
||||
case object PublicChatView extends Permission("VIEW_PUBLIC_CHAT", "See public chat page")
|
||||
case object GamifyView extends Permission("GAMIFY_VIEW", "See mod leaderboard")
|
||||
case object UserModView extends Permission("USER_SPY", "User profile mod view")
|
||||
case object UserEvaluate extends Permission("USER_EVALUATE", "Request evaluation")
|
||||
case object NotifySlack extends Permission("NOTIFY_SLACK", List(UserModView), "Notify #tavern")
|
||||
|
@ -75,6 +77,17 @@ object Permission {
|
|||
"Lichess team"
|
||||
)
|
||||
|
||||
case object TimeoutMod
|
||||
extends Permission(
|
||||
"TIMEOUT_MOD",
|
||||
List(
|
||||
ChatTimeout,
|
||||
PublicChatView,
|
||||
GamifyView
|
||||
),
|
||||
"Timeout mod"
|
||||
)
|
||||
|
||||
case object Hunter
|
||||
extends Permission(
|
||||
"HUNTER",
|
||||
|
@ -102,10 +115,11 @@ object Permission {
|
|||
extends Permission(
|
||||
"SHUSHER",
|
||||
List(
|
||||
LichessTeam,
|
||||
TimeoutMod,
|
||||
ViewPrivateComms,
|
||||
Shadowban,
|
||||
SetKidMode,
|
||||
ChatTimeout,
|
||||
ModerateForum,
|
||||
ReportBan,
|
||||
ModMessage,
|
||||
|
@ -167,6 +181,7 @@ object Permission {
|
|||
Shadowban,
|
||||
SetKidMode,
|
||||
ChatTimeout,
|
||||
PublicChatView,
|
||||
ModerateForum,
|
||||
ReportBan,
|
||||
ModMessage,
|
||||
|
@ -191,6 +206,7 @@ object Permission {
|
|||
),
|
||||
"Misc mod" -> List(
|
||||
SeeReport,
|
||||
GamifyView,
|
||||
Appeals,
|
||||
UserSearch,
|
||||
MonitoredMod,
|
||||
|
@ -231,6 +247,7 @@ object Permission {
|
|||
),
|
||||
"Package" -> List(
|
||||
LichessTeam,
|
||||
TimeoutMod,
|
||||
Hunter,
|
||||
Shusher,
|
||||
Admin,
|
||||
|
|
Loading…
Reference in New Issue