Skip to content

Commit

Permalink
hide muted appeal messages in mod timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 25, 2024
1 parent 457d4f7 commit 0fa1cc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions modules/api/src/main/ModTimeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ case class ModTimeline(
lazy val all: List[Event] =
val reportEvents: List[Event] = reports.flatMap: r =>
r.done.map(ReportClose(r, _)).toList ::: reportAtoms(r)
val appealMsgs: List[Event] = appeal.so(_.msgs.toList)
val playBans: List[Event] = playbanRecord.so(_.bans.toList).toNel.map(PlayBans(_)).toList
val appealMsgs: List[Event] = appeal.so: a =>
a.msgs.toList.takeWhile: msg =>
a.mutedSince.fold(true)(mutedAt => msg.at.isBefore(mutedAt))
val playBans: List[Event] = playbanRecord.so(_.bans.toList).toNel.map(PlayBans(_)).toList
val concat: List[Event] =
modLog ::: appealMsgs ::: notes ::: reportEvents ::: playBans ::: flaggedPublicLines
// latest first
Expand Down
7 changes: 5 additions & 2 deletions modules/appeal/src/main/Appeal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import lila.ui.Icon

case class Appeal(
@Key("_id") id: AppealId,
msgs: Vector[AppealMsg],
status: Appeal.Status, // from the moderators POV
msgs: Vector[AppealMsg], // chronological order, oldest first
status: Appeal.Status, // from the moderators POV
createdAt: Instant,
updatedAt: Instant,
// date of first player message without a mod reply
Expand Down Expand Up @@ -50,6 +50,9 @@ case class Appeal(
def read = copy(status = Appeal.Status.Read)
def toggleMute = if isMuted then read else copy(status = Appeal.Status.Muted)

lazy val mutedSince: Option[Instant] = isMuted.so:
msgs.reverse.takeWhile(m => !isByMod(m)).lastOption.map(_.at)

def isByMod(msg: AppealMsg) = msg.by != id

object Appeal:
Expand Down

0 comments on commit 0fa1cc9

Please sign in to comment.