appeals WIP
parent
1e5543eac7
commit
51efdd2d34
|
@ -45,6 +45,7 @@ final class Env(
|
|||
val simul: lila.simul.Env,
|
||||
val relation: lila.relation.Env,
|
||||
val report: lila.report.Env,
|
||||
val appeal: lila.appeal.Env,
|
||||
val pref: lila.pref.Env,
|
||||
val chat: lila.chat.Env,
|
||||
val puzzle: lila.puzzle.Env,
|
||||
|
@ -231,6 +232,7 @@ final class EnvBoot(
|
|||
lazy val simul: lila.simul.Env = wire[lila.simul.Env]
|
||||
lazy val relation: lila.relation.Env = wire[lila.relation.Env]
|
||||
lazy val report: lila.report.Env = wire[lila.report.Env]
|
||||
lazy val appeal: lila.appeal.Env = wire[lila.appeal.Env]
|
||||
lazy val pref: lila.pref.Env = wire[lila.pref.Env]
|
||||
lazy val chat: lila.chat.Env = wire[lila.chat.Env]
|
||||
lazy val puzzle: lila.puzzle.Env = wire[lila.puzzle.Env]
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package controllers
|
||||
|
||||
import play.api.data._
|
||||
import play.api.data.Forms._
|
||||
import play.api.mvc._
|
||||
|
||||
import lila.api.Context
|
||||
import lila.app._
|
||||
import views._
|
||||
|
||||
final class Appeal(env: Env) extends LilaController(env) {
|
||||
|
||||
// def form =
|
||||
// Auth { implicit ctx => _ =>
|
||||
// env.appeal.forms.create map {
|
||||
// case (form, captcha) => Ok(html.report.form(form, user, captcha))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -537,6 +537,9 @@ POST /report/:id/process controllers.Report.process(id: String)
|
|||
POST /report/:id/xfiles controllers.Report.xfiles(id: String)
|
||||
GET /report/:username/cheat-inquiry controllers.Report.currentCheatInquiry(username: String)
|
||||
|
||||
# Appeal
|
||||
GET /appeal controllers.Appeal.form
|
||||
|
||||
# Stats
|
||||
GET /stat/rating/distribution/:perf controllers.Stat.ratingDistribution(perf: String)
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package lila.appeal
|
||||
|
||||
import lila.user.User
|
||||
import org.joda.time.DateTime
|
||||
|
||||
case class Appeal(
|
||||
_id: User.ID,
|
||||
msgs: List[AppealMsg],
|
||||
status: Appeal.Status,
|
||||
createdAt: DateTime,
|
||||
updatedAt: DateTime
|
||||
)
|
||||
|
||||
object Appeal {
|
||||
|
||||
sealed trait Status {
|
||||
val key = toString.toLowerCase
|
||||
}
|
||||
object Status {
|
||||
case object Unread extends Status
|
||||
case object Read extends Status
|
||||
case object Closed extends Status
|
||||
case object Muted extends Status
|
||||
val all = List[Status](Unread, Read, Closed, Muted)
|
||||
def apply(key: String) = all.find(_.key == key)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case class AppealMsg(
|
||||
by: User.ID,
|
||||
text: String,
|
||||
at: DateTime
|
||||
)
|
|
@ -0,0 +1,9 @@
|
|||
package lila.appeal
|
||||
|
||||
import lila.db.dsl._
|
||||
|
||||
final class AppealApi(
|
||||
coll: Coll
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package lila.appeal
|
||||
|
||||
import play.api.data._
|
||||
import play.api.data.Forms._
|
||||
import play.api.data.validation._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import lila.user.User
|
||||
|
||||
final class DataForm {
|
||||
|
||||
// val create = Form(
|
||||
// mapping(
|
||||
// "username" -> lila.user.DataForm.historicalUsernameField.verifying(
|
||||
// "Unknown username", {
|
||||
// blockingFetchUser(_).isDefined
|
||||
// }
|
||||
// ),
|
||||
// "reason" -> text.verifying("error.required", Reason.keys contains _),
|
||||
// "text" -> text(minLength = 5, maxLength = 2000),
|
||||
// "gameId" -> text,
|
||||
// "move" -> text
|
||||
// )({
|
||||
// case (username, reason, text, gameId, move) =>
|
||||
// ReportSetup(
|
||||
// user = blockingFetchUser(username) err "Unknown username " + username,
|
||||
// reason = reason,
|
||||
// text = text,
|
||||
// gameId = gameId,
|
||||
// move = move
|
||||
// )
|
||||
// })(_.export.some).verifying(captchaFailMessage, validateCaptcha _).verifying(cheatLinkConstraint)
|
||||
// )
|
||||
|
||||
// def createWithCaptcha = withCaptcha(create)
|
||||
|
||||
// val flag = Form(
|
||||
// mapping(
|
||||
// "username" -> lila.user.DataForm.historicalUsernameField,
|
||||
// "resource" -> nonEmptyText,
|
||||
// "text" -> text(minLength = 3, maxLength = 140)
|
||||
// )(ReportFlag.apply)(ReportFlag.unapply)
|
||||
// )
|
||||
|
||||
// private def blockingFetchUser(username: String) =
|
||||
// lightUserAsync(User normalize username).await(1 second, "reportUser")
|
||||
// }
|
||||
|
||||
// private[report] case class ReportFlag(
|
||||
// username: String,
|
||||
// resource: String,
|
||||
// text: String
|
||||
// )
|
||||
|
||||
// private[report] case class ReportSetup(
|
||||
// user: LightUser,
|
||||
// reason: String,
|
||||
// text: String,
|
||||
// gameId: String,
|
||||
// move: String
|
||||
// ) {
|
||||
|
||||
// def suspect = SuspectId(user.id)
|
||||
|
||||
// def export = (user.name, reason, text, gameId, move)
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package lila.appeal
|
||||
|
||||
import lila.db.dsl._
|
||||
import reactivemongo.api.bson._
|
||||
|
||||
private[appeal] object BsonHandlers {
|
||||
|
||||
import Appeal.Status
|
||||
|
||||
implicit val statusHandler = lila.db.dsl.quickHandler[Status](
|
||||
{
|
||||
case BSONString(v) => Status(v) | Status.Closed
|
||||
case _ => Status.Closed
|
||||
},
|
||||
s => BSONString(s.key)
|
||||
)
|
||||
|
||||
// implicit val appealMsgHandler = Macros.handler[AppealMsg]
|
||||
implicit val appealHandler = Macros.handler[Appeal]
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package lila.appeal
|
||||
|
||||
import com.softwaremill.macwire._
|
||||
|
||||
import lila.common.config._
|
||||
|
||||
@Module
|
||||
final class Env(
|
||||
db: lila.db.Db,
|
||||
userRepo: lila.user.UserRepo,
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
private val coll = db(CollName("appeal"))
|
||||
|
||||
// lazy val forms = wire[ClasForm]
|
||||
|
||||
lazy val api: AppealApi = wire[AppealApi]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package lila
|
||||
|
||||
package object appeal extends PackageObject {
|
||||
|
||||
private[appeal] val logger = lila.log("appeal")
|
||||
}
|
Loading…
Reference in New Issue