start modlog implementation
This commit is contained in:
parent
5f7a4043f2
commit
8b6c0201d0
|
@ -22,6 +22,7 @@ object User extends LilaController {
|
||||||
def bookmarkApi = env.bookmark.api
|
def bookmarkApi = env.bookmark.api
|
||||||
def securityStore = env.security.store
|
def securityStore = env.security.store
|
||||||
def firewall = env.security.firewall
|
def firewall = env.security.firewall
|
||||||
|
def modlogApi = env.modlog.api
|
||||||
|
|
||||||
def show(username: String) = showFilter(username, "all", 1)
|
def show(username: String) = showFilter(username, "all", 1)
|
||||||
|
|
||||||
|
@ -93,9 +94,17 @@ object User extends LilaController {
|
||||||
}
|
}
|
||||||
|
|
||||||
def engine(username: String) = Secure(Permission.MarkEngine) { _ ⇒
|
def engine(username: String) = Secure(Permission.MarkEngine) { _ ⇒
|
||||||
_ ⇒
|
me ⇒
|
||||||
IORedirect {
|
IORedirect {
|
||||||
eloUpdater adjust username map { _ ⇒ routes.User show username }
|
for {
|
||||||
|
userOption ← userRepo byId username
|
||||||
|
_ ← userOption.fold(
|
||||||
|
user ⇒ for {
|
||||||
|
_ ← eloUpdater adjust user
|
||||||
|
_ ← modlogApi.engine(me, user, !user.engine)
|
||||||
|
} yield (),
|
||||||
|
io())
|
||||||
|
} yield routes.User show username
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,10 +129,14 @@ final class CoreEnv private (application: Application, val settings: Settings) {
|
||||||
mongodb = mongodb.connection,
|
mongodb = mongodb.connection,
|
||||||
settings = settings)
|
settings = settings)
|
||||||
|
|
||||||
lazy val titivate = new core.Titivate(
|
lazy val titivate = new lila.core.Titivate(
|
||||||
gameRepo = game.gameRepo,
|
gameRepo = game.gameRepo,
|
||||||
finisher = round.finisher,
|
finisher = round.finisher,
|
||||||
bookmarkApi = bookmark.api)
|
bookmarkApi = bookmark.api)
|
||||||
|
|
||||||
|
lazy val modlog = new lila.modlog.ModlogEnv(
|
||||||
|
settings = settings,
|
||||||
|
mongodb = mongodb.apply _)
|
||||||
}
|
}
|
||||||
|
|
||||||
object CoreEnv {
|
object CoreEnv {
|
||||||
|
|
|
@ -121,6 +121,8 @@ final class Settings(config: Config) {
|
||||||
val ActorLobbyHub = "lobby_hub"
|
val ActorLobbyHub = "lobby_hub"
|
||||||
val ActorMonitorHub = "monitor_hub"
|
val ActorMonitorHub = "monitor_hub"
|
||||||
|
|
||||||
|
val ModlogCollectionModlog = getString("modlog.collection.modlog")
|
||||||
|
|
||||||
private def millis(name: String): Int = getMilliseconds(name).toInt
|
private def millis(name: String): Int = getMilliseconds(name).toInt
|
||||||
|
|
||||||
private def seconds(name: String): Int = millis(name) / 1000
|
private def seconds(name: String): Int = millis(name) / 1000
|
||||||
|
|
|
@ -20,17 +20,12 @@ final class EloUpdater(
|
||||||
|
|
||||||
val adjustTo = User.STARTING_ELO
|
val adjustTo = User.STARTING_ELO
|
||||||
|
|
||||||
def adjust(username: String) = for {
|
def adjust(u: User) = for {
|
||||||
uOption ← userRepo byId username
|
|
||||||
_ ← uOption.fold(
|
|
||||||
u ⇒ for {
|
|
||||||
_ ← userRepo toggleEngine u.id
|
_ ← userRepo toggleEngine u.id
|
||||||
_ ← (!u.engine && u.elo > adjustTo).fold(
|
_ ← (!u.engine && u.elo > adjustTo).fold(
|
||||||
userRepo.setElo(u.id, adjustTo) flatMap { _ ⇒
|
userRepo.setElo(u.id, adjustTo) flatMap { _ ⇒
|
||||||
historyRepo.addEntry(u.id, adjustTo, entryType = HistoryRepo.TYPE_ADJUST)
|
historyRepo.addEntry(u.id, adjustTo, entryType = HistoryRepo.TYPE_ADJUST)
|
||||||
},
|
},
|
||||||
io())
|
io())
|
||||||
} yield (),
|
|
||||||
io())
|
|
||||||
} yield ()
|
} yield ()
|
||||||
}
|
}
|
||||||
|
|
23
app/modlog/Modlog.scala
Normal file
23
app/modlog/Modlog.scala
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package lila
|
||||||
|
package modlog
|
||||||
|
|
||||||
|
import user.User
|
||||||
|
|
||||||
|
import org.joda.time.DateTime
|
||||||
|
import org.scala_tools.time.Imports._
|
||||||
|
|
||||||
|
case class Modlog(
|
||||||
|
mod: String,
|
||||||
|
user: Option[String],
|
||||||
|
action: String,
|
||||||
|
date: DateTime = DateTime.now)
|
||||||
|
|
||||||
|
object Modlog {
|
||||||
|
|
||||||
|
val engine = "engine"
|
||||||
|
val unengine = "un-engine"
|
||||||
|
val mute = "mute"
|
||||||
|
val unmute = "un-mute"
|
||||||
|
val ipban = "ipban"
|
||||||
|
val deletePost = "remove post"
|
||||||
|
}
|
15
app/modlog/ModlogApi.scala
Normal file
15
app/modlog/ModlogApi.scala
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package lila
|
||||||
|
package modlog
|
||||||
|
|
||||||
|
import user.User
|
||||||
|
|
||||||
|
import scalaz.effects._
|
||||||
|
|
||||||
|
final class ModlogApi(repo: ModlogRepo) {
|
||||||
|
|
||||||
|
def engine(mod: User, user: User, v: Boolean) = add {
|
||||||
|
Modlog(mod.id, user.id.some, v.fold(Modlog.engine, Modlog.unengine)).pp
|
||||||
|
}
|
||||||
|
|
||||||
|
private def add(modLog: Modlog): IO[Unit] = repo saveIO modLog
|
||||||
|
}
|
18
app/modlog/ModlogEnv.scala
Normal file
18
app/modlog/ModlogEnv.scala
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package lila
|
||||||
|
package modlog
|
||||||
|
|
||||||
|
import com.mongodb.casbah.MongoCollection
|
||||||
|
|
||||||
|
import core.Settings
|
||||||
|
|
||||||
|
final class ModlogEnv(
|
||||||
|
settings: Settings,
|
||||||
|
mongodb: String ⇒ MongoCollection) {
|
||||||
|
|
||||||
|
import settings._
|
||||||
|
|
||||||
|
lazy val modlogRepo = new ModlogRepo(mongodb(ModlogCollectionModlog))
|
||||||
|
|
||||||
|
lazy val api = new ModlogApi(
|
||||||
|
repo = modlogRepo)
|
||||||
|
}
|
18
app/modlog/ModlogRepo.scala
Normal file
18
app/modlog/ModlogRepo.scala
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package lila
|
||||||
|
package modlog
|
||||||
|
|
||||||
|
import user.User
|
||||||
|
|
||||||
|
import com.novus.salat._
|
||||||
|
import com.novus.salat.dao._
|
||||||
|
import com.mongodb.casbah.{ MongoCollection, WriteConcern }
|
||||||
|
import com.mongodb.casbah.Imports._
|
||||||
|
import scalaz.effects._
|
||||||
|
|
||||||
|
class ModlogRepo(collection: MongoCollection)
|
||||||
|
extends SalatDAO[Modlog, String](collection) {
|
||||||
|
|
||||||
|
def saveIO(modlog: Modlog): IO[Unit] = io {
|
||||||
|
save(modlog)
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,6 @@ final class Flood {
|
||||||
}
|
}
|
||||||
type Messages = List[Message]
|
type Messages = List[Message]
|
||||||
|
|
||||||
// uid, [date, message]
|
|
||||||
private val messages = Builder.expiry[String, Messages](ttl)
|
private val messages = Builder.expiry[String, Messages](ttl)
|
||||||
|
|
||||||
def filterMessage[A](uid: String, text: String)(op: ⇒ Unit) {
|
def filterMessage[A](uid: String, text: String)(op: ⇒ Unit) {
|
||||||
|
|
|
@ -20,6 +20,9 @@ analyse {
|
||||||
security {
|
security {
|
||||||
collection.security = security
|
collection.security = security
|
||||||
}
|
}
|
||||||
|
modlog {
|
||||||
|
collection.modlog = modlog
|
||||||
|
}
|
||||||
firewall {
|
firewall {
|
||||||
enabled=true
|
enabled=true
|
||||||
block_cookie=fEKHA4zI23ZrZrom
|
block_cookie=fEKHA4zI23ZrZrom
|
||||||
|
|
7
todo
7
todo
|
@ -31,11 +31,14 @@ move while disconnected = move lost. should reload the page on ack timeout.
|
||||||
finish games per day chart
|
finish games per day chart
|
||||||
untranslated = https://github.com/ornicar/lila/issues/4
|
untranslated = https://github.com/ornicar/lila/issues/4
|
||||||
list of adjustments
|
list of adjustments
|
||||||
disable pgn4web onboard features
|
|
||||||
game stats timeline issues http://en.lichess.org/forum/lichess-feedback/move-times
|
game stats timeline issues http://en.lichess.org/forum/lichess-feedback/move-times
|
||||||
propagate IP ban to the user
|
propagate IP ban to the user
|
||||||
verify firewall cookie is persistent
|
forum post IP ban
|
||||||
admin ip search interface
|
admin ip search interface
|
||||||
analyse: show main line for every move http://en.lichess.org/forum/lichess-feedback/about-the-analysis-feature#5
|
analyse: show main line for every move http://en.lichess.org/forum/lichess-feedback/about-the-analysis-feature#5
|
||||||
show victory in analysis page + other suggestions http://en.lichess.org/forum/lichess-feedback/a-couple-of-feature-requests#2
|
show victory in analysis page + other suggestions http://en.lichess.org/forum/lichess-feedback/a-couple-of-feature-requests#2
|
||||||
only one stockfish instance for moves and analysis. Use a todo with two queues.
|
only one stockfish instance for moves and analysis. Use a todo with two queues.
|
||||||
|
|
||||||
|
next deploy
|
||||||
|
-----------
|
||||||
|
db.createCollection("modlog",{capped:true, size: 1000000})
|
||||||
|
|
Loading…
Reference in a new issue