From 7de865795f5f3d921d5a998f042c1002060d66ea Mon Sep 17 00:00:00 2001 From: To-om Date: Thu, 4 Feb 2021 12:35:39 +0100 Subject: [PATCH] #1773 Use only organisation Ids to compare links --- thehive/app/org/thp/thehive/services/OrganisationSrv.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thehive/app/org/thp/thehive/services/OrganisationSrv.scala b/thehive/app/org/thp/thehive/services/OrganisationSrv.scala index 6d4115acd8..bc8221e55c 100644 --- a/thehive/app/org/thp/thehive/services/OrganisationSrv.scala +++ b/thehive/app/org/thp/thehive/services/OrganisationSrv.scala @@ -108,11 +108,12 @@ class OrganisationSrv @Inject() ( authContext: AuthContext, graph: Graph ): Try[Unit] = { + val toOrgIds = toOrganisations.map(_.fold(identity, getByName(_)._id.getOrFail("Organisation").get)).toSet val (orgToAdd, orgToRemove) = get(fromOrg) .links ._id .toIterator - .foldLeft((toOrganisations.toSet, Set.empty[EntityId])) { + .foldLeft((toOrgIds, Set.empty[EntityId])) { case ((toAdd, toRemove), o) if toAdd.contains(o) => (toAdd - o, toRemove) case ((toAdd, toRemove), o) => (toAdd, toRemove + o) }