From 7846f8e57e9c48f4b980b6e69d306d93e84c5ade Mon Sep 17 00:00:00 2001 From: To-om Date: Mon, 17 May 2021 13:45:14 +0200 Subject: [PATCH] #1940 Unset case Id in alert when the case is removed --- thehive/app/org/thp/thehive/services/CaseSrv.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/thehive/app/org/thp/thehive/services/CaseSrv.scala b/thehive/app/org/thp/thehive/services/CaseSrv.scala index df81f20d61..9abec18158 100644 --- a/thehive/app/org/thp/thehive/services/CaseSrv.scala +++ b/thehive/app/org/thp/thehive/services/CaseSrv.scala @@ -214,7 +214,12 @@ class CaseSrv @Inject() ( .getOrFail("Share") .flatMap { case share if share.owner => - get(`case`).shares.toSeq.toTry(s => shareSrv.unshareCase(s._id)).map(_ => get(`case`).remove()) + get(`case`) + .sideEffect(_.alert.update(_.caseId, EntityId.empty)) + .shares + .toSeq + .toTry(s => shareSrv.unshareCase(s._id)) + .map(_ => get(`case`).remove()) case _ => throw BadRequestError("Your organisation must be owner of the case") // shareSrv.unshareCase(share._id)