comple mod permission refinements - closes lichess-org/tavern#53

pull/8342/head
Thibault Duplessis 2021-03-09 12:34:41 +01:00
parent f72b0fb3dc
commit b0a95909a2
4 changed files with 13 additions and 10 deletions

View File

@ -261,6 +261,7 @@ final class Mod(
}
}
html.mod.communication(
me,
user,
(povs zip chats) collect {
case (p, Some(c)) if c.nonEmpty => p -> c

View File

@ -391,7 +391,7 @@ final class User(
val userLoginsFu = env.security.userLogins(user, nbOthers)
val others = userLoginsFu flatMap { userLogins =>
loginsTableData(user, userLogins, nbOthers) map {
html.user.mod.otherUsers(user, _)
html.user.mod.otherUsers(holder, user, _)
}
}
val identification = userLoginsFu map { spy =>

View File

@ -5,13 +5,15 @@ import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.String.html.richText
import lila.hub.actorApi.shutup.PublicSource
import lila.user.{ Holder, User }
import controllers.routes
object communication {
def apply(
u: lila.user.User,
mod: Holder,
u: User,
players: List[(lila.game.Pov, lila.chat.MixedChat)],
convos: List[lila.msg.MsgConvo],
publicLines: List[lila.shutup.PublicLine],
@ -54,7 +56,7 @@ object communication {
),
isGranted(_.UserModView) option frag(
div(cls := "mod-zone none"),
views.html.user.mod.otherUsers(u, logins)(ctx)(cls := "communication__logins")
views.html.user.mod.otherUsers(mod, u, logins)(ctx)(cls := "communication__logins")
),
history.nonEmpty option frag(
h2("Moderation history"),

View File

@ -9,8 +9,9 @@ import lila.app.ui.ScalatagsTemplate._
import lila.evaluation.Display
import lila.mod.ModPresets
import lila.playban.RageSit
import lila.security.Granter
import lila.security.{ Permission, UserLogins }
import lila.user.User
import lila.user.{ Holder, User }
object mod {
private def mzSection(key: String) = div(id := s"mz_$key", cls := "mz-section")
@ -516,7 +517,7 @@ object mod {
if (nb > 0) td(cls := "i", dataSort := nb)(content)
else td
def otherUsers(u: User, data: UserLogins.TableData)(implicit ctx: Context): Tag = {
def otherUsers(mod: Holder, u: User, data: UserLogins.TableData)(implicit ctx: Context): Tag = {
import data._
mzSection("others")(
table(cls := "slist")(
@ -529,7 +530,7 @@ object mod {
a(cls := "more-others")("Load more")
)
),
th("Email"),
isGranted(_.Admin) option th("Email"),
sortNumberTh("Same"),
th("Games"),
sortNumberTh(playban)(cls := "i", title := "Playban"),
@ -547,17 +548,16 @@ object mod {
),
tbody(
othersWithEmail.others.map { case other @ UserLogins.OtherUser(o, _, _) =>
val dox = isGranted(_.Admin) || (o.lameOrAlt && !o.hasTitle)
val userNotes =
notes.filter(n => n.to == o.id && (ctx.me.exists(n.isFrom) || isGranted(_.Admin)))
tr(
dataTags := s"${other.ips.mkString(" ")} ${other.fps.mkString(" ")}",
cls := (o == u) option "same"
)(
if (dox || o == u) td(dataSort := o.id)(userLink(o, withBestRating = true, params = "?mod"))
else td,
if (dox) td(othersWithEmail emailValueOf o)
if (o == u || Granter.canViewAltUsernames(mod, u))
td(dataSort := o.id)(userLink(o, withBestRating = true, params = "?mod"))
else td,
isGranted(_.Admin) option td(othersWithEmail emailValueOf o),
td(
// show prints and ips separately
dataSort := other.score + (other.ips.nonEmpty ?? 1000000) + (other.fps.nonEmpty ?? 3000000)