recover invalid requests to gif exporter
parent
081dfcfc7b
commit
b6afa99dd1
|
@ -522,6 +522,8 @@ final class Study(
|
|||
Ok.chunked(stream)
|
||||
.pipe(asAttachmentStream(s"${env.study.pgnDump.filename(study, chapter)}.gif"))
|
||||
.as("image/gif")
|
||||
} recover { case lila.base.LilaInvalid(msg) =>
|
||||
BadRequest(msg)
|
||||
}
|
||||
}(privateUnauthorizedFu(study), privateForbiddenFu(study))
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import play.api.libs.json._
|
|||
import play.api.libs.ws.JsonBodyWritables._
|
||||
import play.api.libs.ws.StandaloneWSClient
|
||||
|
||||
import lila.base.LilaInvalid
|
||||
|
||||
final class GifExport(
|
||||
ws: StandaloneWSClient,
|
||||
url: String
|
||||
|
@ -32,10 +34,11 @@ final class GifExport(
|
|||
)
|
||||
)
|
||||
.stream() flatMap {
|
||||
case res if res.status != 200 =>
|
||||
case res if res.status == 200 => fuccess(res.bodyAsSource)
|
||||
case res if res.status == 400 => fufail(LilaInvalid(res.body))
|
||||
case res =>
|
||||
logger.warn(s"GifExport study ${chapter.studyId}/${chapter._id} ${res.status}")
|
||||
fufail(res.statusText)
|
||||
case res => fuccess(res.bodyAsSource)
|
||||
}
|
||||
|
||||
@annotation.tailrec
|
||||
|
|
Loading…
Reference in New Issue