diff --git a/app/controllers/Importer.scala b/app/controllers/Importer.scala index 64f752fe2d..5e30949f48 100644 --- a/app/controllers/Importer.scala +++ b/app/controllers/Importer.scala @@ -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(