Return game json from import feature

This commit is contained in:
Vincent Velociter 2016-10-27 17:47:51 +02:00
parent 54c560fb24
commit 36e6f63699

View file

@ -20,9 +20,10 @@ object Importer extends LilaController {
def sendGame = OpenBody { implicit ctx =>
implicit def req = ctx.body
env.forms.importForm.bindFromRequest.fold(
failure => fuccess {
Ok(html.game.importGame(failure))
},
failure => negotiate(
html = Ok(html.game.importGame(failure)).fuccess,
api = _ => BadRequest(Json.obj("error" -> "Invalid PGN")).fuccess
),
data => env.importer(data, ctx.userId) flatMap { game =>
(data.analyse.isDefined && game.analysable) ?? {
Env.fishnet.analyser(game, lila.fishnet.Work.Sender(