forum post deletion presets fix

removeCoachApprovedField
Thibault Duplessis 2021-07-08 09:54:38 +02:00
parent 9e000b26fe
commit b2b7a52ee2
3 changed files with 19 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import views._
import lila.app._
import lila.common.{ HTTPRequest, IpAddress }
import lila.msg.MsgPreset
final class ForumPost(env: Env) extends LilaController(env) with ForumController {
@ -89,10 +90,10 @@ final class ForumPost(env: Env) extends LilaController(env) with ForumController
for {
userId <- post.userId
reasonOpt <- forms.deleteWithReason.bindFromRequest().value
reason <- reasonOpt
reason <- reasonOpt.filter(MsgPreset.forumDeletion.presets.contains)
preset =
if (isGranted(_.ModerateForum)) lila.msg.MsgPreset.forumDeletionByModerator
else lila.msg.MsgPreset.forumDeletionByTeamLeader
if (isGranted(_.ModerateForum)) MsgPreset.forumDeletion.byModerator
else MsgPreset.forumDeletion.byTeamLeader
} env.msg.api.systemPost(userId, preset(reason))
NoContent
}

View File

@ -212,12 +212,7 @@ object topic {
cls := "form-control"
)(
option(value := "")("no message"),
List(
"public shaming",
"disrespecting other players",
"spamming",
"inappropriate behavior"
).map { reason =>
lila.msg.MsgPreset.forumDeletion.presets.map { reason =>
option(value := reason)(reason)
}
),

View File

@ -38,10 +38,20 @@ To follow new players, you must first unfollow some on https://lichess.org/@/$us
Thank you for your understanding."""
)
def forumDeletionByModerator = forumDeletion("A moderator") _
object forumDeletion {
def forumDeletionByTeamLeader = forumDeletion("A team leader") _
val presets = List(
"public shaming",
"disrespecting other players",
"spamming",
"inappropriate behavior"
)
private def forumDeletion(by: String)(reason: String) =
s"""$by deleted one of your posts for this reason: $reason. Please read our Forum-Etiquette: https://lichess.org/page/forum-etiquette"""
def byModerator = compose("A moderator") _
def byTeamLeader = compose("A team leader") _
private def compose(by: String)(reason: String) =
s"""$by deleted one of your posts for this reason: $reason. Please read our Forum-Etiquette: https://lichess.org/page/forum-etiquette"""
}
}