Display to mods when conv threads are truncated

pull/9810/head
kraktus 2021-09-15 14:19:31 +02:00
parent 2cc0803a10
commit 767849a396
4 changed files with 29 additions and 12 deletions

View File

@ -18,7 +18,7 @@ object communication {
mod: Holder,
u: User,
players: List[(lila.game.Pov, lila.chat.MixedChat)],
convos: List[lila.msg.MsgConvo],
convos: List[lila.msg.ModMsgConvo],
publicLines: List[lila.shutup.PublicLine],
notes: List[lila.user.Note],
history: List[lila.mod.Modlog],
@ -154,16 +154,19 @@ object communication {
),
div(cls := "threads")(
h2("Recent inbox messages"),
convos.map { convo =>
convos.map { modConvo =>
div(cls := "thread")(
p(cls := "title")(strong(lightUserLink(convo.contact))),
p(cls := "title")(strong(lightUserLink(modConvo.convo.contact))),
table(cls := "slist")(
tbody(
convo.msgs.reverse.map { msg =>
modConvo.truncated option div(cls := "truncated-convo")(
s"Truncated, showing last ${modConvo.convo.msgs.length} messages"
),
modConvo.convo.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 convo.contact.name)),
td(strong(if (author) u.username else modConvo.convo.contact.name)),
td(cls := "message")(highlightBad(msg.text))
)
}

View File

@ -173,7 +173,7 @@ final class MsgApi(
case Some(sender) => multiPost(Holder(sender), Source(dests), text) inject "done"
}
def recentByForMod(user: User, nb: Int): Fu[List[MsgConvo]] =
def recentByForMod(user: User, nb: Int): Fu[List[ModMsgConvo]] =
colls.thread
.find($doc("users" -> user.id))
.sort($sort desc "lastMsg.date")
@ -185,14 +185,17 @@ final class MsgApi(
.find($doc("tid" -> thread.id), msgProjection)
.sort($sort desc "date")
.cursor[Msg]()
.list(10)
.list(11)
.flatMap { msgs =>
lightUserApi async thread.other(user) map { contact =>
MsgConvo(
contact | LightUser.fallback(thread other user),
msgs,
lila.relation.Relations(none, none),
postable = false
ModMsgConvo(
MsgConvo(
contact | LightUser.fallback(thread other user),
msgs.take(10),
lila.relation.Relations(none, none),
postable = false
),
msgs.length == 11
)
}
}

View File

@ -9,3 +9,8 @@ case class MsgConvo(
relations: Relations,
postable: Boolean
)
case class ModMsgConvo(
convo: MsgConvo,
truncated: Boolean
)

View File

@ -113,6 +113,12 @@
margin-bottom: 20px;
}
.thread .truncated-convo {
text-align: center;
font-style: italic;
display: block;
}
.thread .title strong {
font-size: 1.2em;
display: block;