From 3123b8661d166d19559a1fe6c0201b7637d7a66f Mon Sep 17 00:00:00 2001 From: To-om Date: Fri, 26 Jun 2020 17:44:56 +0200 Subject: [PATCH] #1414 Add tasks in case creation API --- dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala | 3 +-- thehive/app/org/thp/thehive/controllers/v1/Conversion.scala | 1 + thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala index ba90dc1300..936d78fc74 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala @@ -5,12 +5,11 @@ import java.util.Date import play.api.libs.json.{Json, OFormat, OWrites} case class InputTask( - caseId: String, title: String, group: Option[String] = None, description: Option[String] = None, status: Option[String] = None, - flag: Boolean = false, + flag: Option[Boolean] = None, startDate: Option[Date] = None, endDate: Option[Date] = None, order: Option[Int] = None, diff --git a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala index c26cd4f43e..2cfb78652d 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala @@ -168,6 +168,7 @@ object Conversion { .withFieldComputed(_.status, _.status.fold(TaskStatus.Waiting)(TaskStatus.withName)) .withFieldComputed(_.order, _.order.getOrElse(0)) .withFieldComputed(_.group, _.group.getOrElse("default")) + .withFieldComputed(_.flag, _.flag.getOrElse(false)) .transform } diff --git a/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala index fc12837d7f..71ba09ff28 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala @@ -50,10 +50,12 @@ class TaskCtrl @Inject() ( def create: Action[AnyContent] = entrypoint("create task") .extract("task", FieldsParser[InputTask]) + .extract("caseId", FieldsParser[String]) .authTransaction(db) { implicit request => implicit graph => val inputTask: InputTask = request.body("task") + val caseId: String = request.body("caseId") for { - case0 <- caseSrv.getOrFail(inputTask.caseId) + case0 <- caseSrv.getOrFail(caseId) createdTask <- taskSrv.create(inputTask.toTask, None) organisation <- organisationSrv.getOrFail(request.organisation) _ <- shareSrv.shareTask(createdTask, case0, organisation)