Skip to content

Commit 87f0c4b

Browse files
author
To-om
committed
#14 Fix get nstats parameter (bodyParser doesn't work in GET request)
1 parent f63d737 commit 87f0c4b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

thehive-backend/app/controllers/Case.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.elastic4play.services.JsonFormat.{ aggReads, queryReads }
2525
import models.{ Case, CaseStatus }
2626
import services.{ CaseSrv, TaskSrv }
2727
import services.CaseMergeSrv
28+
import scala.util.Try
2829

2930
@Singleton
3031
class CaseCtrl @Inject() (
@@ -47,13 +48,15 @@ class CaseCtrl @Inject() (
4748
}
4849

4950
@Timed
50-
def get(id: String) = authenticated(Role.read).async(fieldsBodyParser) { implicit request
51-
val nparent = request.body.getLong("nparent").getOrElse(0L).toInt
52-
val withStats = request.body.getBoolean("nstats").getOrElse(false)
51+
def get(id: String) = authenticated(Role.read).async { implicit request
52+
val withStats = for {
53+
statsValues <- request.queryString.get("nstats")
54+
firstValue <- statsValues.headOption
55+
} yield Try(firstValue.toBoolean).getOrElse(firstValue == "1")
5356

5457
for {
5558
caze caseSrv.get(id)
56-
casesWithStats auxSrv.apply(caze, nparent, withStats)
59+
casesWithStats auxSrv.apply(caze, 0, withStats.getOrElse(false))
5760
} yield renderer.toOutput(OK, casesWithStats)
5861
}
5962

0 commit comments

Comments
 (0)