notify simul creation
This commit is contained in:
parent
2d05cfa141
commit
e151987aff
|
@ -84,7 +84,7 @@ object Simul extends LilaController {
|
|||
implicit val req = ctx.body
|
||||
newForm(me).bindFromRequest.fold(
|
||||
err => BadRequest(html.simul.form(err, env.forms)).fuccess,
|
||||
setup => env.repo.create(setup, me) map { simul =>
|
||||
setup => env.api.create(setup, me) map { simul =>
|
||||
Redirect(routes.Simul.show(simul.id))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -24,6 +24,18 @@ private[simul] final class SimulApi(
|
|||
site: ActorSelection,
|
||||
repo: SimulRepo) {
|
||||
|
||||
def create(setup: SimulSetup, me: User): Fu[Simul] = {
|
||||
val simul = Simul.make(
|
||||
name = setup.name,
|
||||
clock = SimulClock(
|
||||
limit = setup.clockTime * 60,
|
||||
increment = setup.clockIncrement,
|
||||
hostExtraTime = setup.clockExtra * 60),
|
||||
variants = setup.variants.flatMap { chess.variant.Variant(_) },
|
||||
host = me)
|
||||
(repo create simul) >>- publish() inject simul
|
||||
}
|
||||
|
||||
def addApplicant(simulId: Simul.ID, user: User, variantKey: String) {
|
||||
WithSimul(repo.findCreated, simulId) { simul =>
|
||||
Variant(variantKey).filter(simul.variants.contains).fold(simul) { variant =>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package lila.simul
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import reactivemongo.bson._
|
||||
import reactivemongo.core.commands._
|
||||
import org.joda.time.DateTime
|
||||
|
||||
import chess.Status
|
||||
import chess.variant.Variant
|
||||
|
@ -65,17 +65,8 @@ private[simul] final class SimulRepo(simulColl: Coll) {
|
|||
BSONDocument("status" -> BSONDocument("$ne" -> SimulStatus.Finished.id))
|
||||
).cursor[Simul].collect[List]()
|
||||
|
||||
def create(setup: SimulSetup, me: User): Fu[Simul] = {
|
||||
val simul = Simul.make(
|
||||
name = setup.name,
|
||||
clock = SimulClock(
|
||||
limit = setup.clockTime * 60,
|
||||
increment = setup.clockIncrement,
|
||||
hostExtraTime = setup.clockExtra * 60),
|
||||
variants = setup.variants.flatMap { chess.variant.Variant(_) },
|
||||
host = me)
|
||||
simulColl insert simul inject simul
|
||||
}
|
||||
def create(simul: Simul): Funit =
|
||||
simulColl insert simul void
|
||||
|
||||
def update(simul: Simul) =
|
||||
simulColl.update(BSONDocument("_id" -> simul.id), simul).void
|
||||
|
|
Loading…
Reference in a new issue