Skip to content

Commit

Permalink
#1312 #1311 Use case template from user when importing an alert
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed May 17, 2020
1 parent b95aa9b commit edf2b03
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,17 @@ class AlertCtrl @Inject() (

def createCase(alertId: String): Action[AnyContent] =
entrypoint("create case from alert")
.extract("caseTemplate", FieldsParser.string.optional.on("caseTemplate"))
.authTransaction(db) { implicit request => implicit graph =>
val caseTemplate: Option[String] = request.body("caseTemplate")
for {
(alert, organisation) <- alertSrv
.get(alertId)
.can(Permissions.manageAlert)
.alertUserOrganisation(Permissions.manageCase)
.getOrFail()
richCase <- alertSrv.createCase(alert, None, organisation)
.getOrFail("Alert")
alertWithCaseTemplate = caseTemplate.fold(alert)(ct => alert.copy(caseTemplate = Some(ct)))
richCase <- alertSrv.createCase(alertWithCaseTemplate, None, organisation)
} yield Results.Created(richCase.toJson)
}

Expand Down

0 comments on commit edf2b03

Please sign in to comment.