diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala index 0f10ef04e1..7ca6a54f3e 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala @@ -14,7 +14,7 @@ case class InputAlert( title: String, description: String, severity: Option[Int] = None, - date: Date = new Date, + date: Option[Date] = None, tags: Set[String] = Set.empty, flag: Option[Boolean] = None, tlp: Option[Int] = None, diff --git a/thehive/app/org/thp/thehive/controllers/v0/Conversion.scala b/thehive/app/org/thp/thehive/controllers/v0/Conversion.scala index 6f1c691c2a..1a35fbbc95 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/Conversion.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/Conversion.scala @@ -93,6 +93,7 @@ object Conversion { .withFieldComputed(_.severity, _.severity.getOrElse(2)) .withFieldComputed(_.tlp, _.tlp.getOrElse(2)) .withFieldComputed(_.pap, _.pap.getOrElse(2)) + .withFieldComputed(_.date, _.date.getOrElse(new Date)) .withFieldConst(_.read, false) .withFieldConst(_.lastSyncDate, new Date) .withFieldConst(_.follow, true) diff --git a/thehive/test/org/thp/thehive/controllers/v0/AlertCtrlTest.scala b/thehive/test/org/thp/thehive/controllers/v0/AlertCtrlTest.scala index ed6a993bb4..ed97d5bbda 100644 --- a/thehive/test/org/thp/thehive/controllers/v0/AlertCtrlTest.scala +++ b/thehive/test/org/thp/thehive/controllers/v0/AlertCtrlTest.scala @@ -89,7 +89,7 @@ class AlertCtrlTest extends PlaySpecification with TestAppBuilder { title = "alert title (create alert test)", description = "alert description (create alert test)", severity = Some(2), - date = now, + date = Some(now), tags = Set("tag1", "tag2"), flag = Some(false), tlp = Some(1), diff --git a/thehive/test/org/thp/thehive/services/notification/triggers/AlertCreatedTest.scala b/thehive/test/org/thp/thehive/services/notification/triggers/AlertCreatedTest.scala index 2df6bc5b28..783ddba02b 100644 --- a/thehive/test/org/thp/thehive/services/notification/triggers/AlertCreatedTest.scala +++ b/thehive/test/org/thp/thehive/services/notification/triggers/AlertCreatedTest.scala @@ -29,7 +29,7 @@ class AlertCreatedTest extends PlaySpecification with TestAppBuilder { title = "alert title (create alert test)", description = "alert description (create alert test)", severity = Some(2), - date = new Date(), + date = Some(new Date()), tags = Set("tag1", "tag2"), flag = Some(false), tlp = Some(1),