Skip to content

Commit

Permalink
Show shadowban directly in the communication page
Browse files Browse the repository at this point in the history
For https://hq.lichess.ovh/#narrow/stream/34-mod-dev/topic/shadowbans.20in.20PMs.20.28request.29/near/432680

TDLR: make it more clear it's not needed to investigate these players, without hovering the username of each of them.
  • Loading branch information
kraktus committed Oct 9, 2021
1 parent 13041d1 commit 2d0e6df
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 19 deletions.
10 changes: 6 additions & 4 deletions app/views/mod/communication.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ object communication {
h2("Recent inbox messages"),
convos.map { modConvo =>
div(cls := "thread")(
p(cls := "title")(strong(lightUserLink(modConvo.convo.contact))),
p(cls := "title")(strong(userLink(modConvo.contact), showSbMark(modConvo.contact))),
table(cls := "slist")(
tbody(
modConvo.truncated option div(cls := "truncated-convo")(
s"Truncated, showing last ${modConvo.convo.msgs.length} messages"
s"Truncated, showing last ${modConvo.msgs.length} messages"
),
modConvo.convo.msgs.reverse.map { msg =>
modConvo.msgs.reverse.map { msg =>
val author = msg.user == u.id
tr(cls := List("post" -> true, "author" -> author))(
td(momentFromNowOnce(msg.date)),
td(strong(if (author) u.username else modConvo.convo.contact.name)),
td(strong(if (author) u.username else modConvo.contact.username)),
td(cls := "message")(highlightBad(msg.text))
)
}
Expand All @@ -189,4 +189,6 @@ object communication {
raw(regex.replaceAllIn(escapeHtmlRaw(text), m => tag(m.toString)))
}
}

private def showSbMark(u: User) = u.marks.troll option span(cls := "user_marks")(iconTag(""))
}
17 changes: 8 additions & 9 deletions modules/msg/src/main/MsgApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,18 @@ final class MsgApi(
.cursor[Msg]()
.list(11)
.flatMap { msgs =>
lightUserApi async thread.other(user) map { contact =>
ModMsgConvo(
MsgConvo(
contact | LightUser.fallback(thread other user),
userRepo named thread.other(user) map {
_.map { contact =>
ModMsgConvo(
contact,
msgs.take(10),
lila.relation.Relations(none, none),
postable = false
),
msgs.length == 11
)
msgs.length == 11
)
}
}
}
}.sequenceFu
}.sequenceFu.map(_.flatten)
}

def deleteAllBy(user: User): Funit =
Expand Down
5 changes: 4 additions & 1 deletion modules/msg/src/main/model.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lila.msg

import lila.common.LightUser
import lila.user.User
import lila.relation.Relations

case class MsgConvo(
Expand All @@ -11,6 +12,8 @@ case class MsgConvo(
)

case class ModMsgConvo(
convo: MsgConvo,
contact: User,
msgs: List[Msg],
relations: Relations,
truncated: Boolean
)
6 changes: 6 additions & 0 deletions ui/site/css/mod/_communication.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'user-marks';

#communication {
h1 {
@extend %flex-between;
Expand Down Expand Up @@ -88,6 +90,10 @@
overflow-y: auto;
}

.user_marks i {
@include user_marks;
}

.player_chats .line,
.threads .post {
opacity: 0.5;
Expand Down
8 changes: 3 additions & 5 deletions ui/site/css/mod/_report.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'user-marks';

$c-report-bg: $c-bg-high;
$c-report-high: $c-brag;
$c-report-high-over: white;
Expand Down Expand Up @@ -139,11 +141,7 @@ $c-report-high-over: white;
}

.user_marks i {
font-size: 0.9em;
background: #dc322f70;
padding: 0.1em 0.4em;
border-radius: 0.3em;
margin: 0 0.2em;
@include user_marks;
}

.appeal-queue {
Expand Down
7 changes: 7 additions & 0 deletions ui/site/css/mod/_user-marks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@mixin user_marks {
font-size: 0.9em;
background: #dc322f70;
padding: 0.1em 0.4em;
border-radius: 0.3em;
margin: 0 0.2em;
}

0 comments on commit 2d0e6df

Please sign in to comment.