Skip to content

Commit

Permalink
[backend] Improve resolve refs to handle multiple same references in …
Browse files Browse the repository at this point in the history
…different destination key
  • Loading branch information
richard-julien committed Sep 19, 2023
1 parent 6d570fe commit dd9fe4b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions opencti-platform/opencti-graphql/src/database/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,15 +711,17 @@ const inputResolveRefs = async (context, user, input, type, entitySetting) => {
const elements = R.uniq(id).map((i) => ({ id: i, destKey, multiple: true }));
fetchingIds.push(...elements);
expectedIds.push(...elements.map((e) => e.id));
} else if (!expectedIds.includes(id)) {
// If resolution is due to embedded ref, the from must be fully resolved
// This will be used to generated a correct stream message
} else { // Single
if (dst === INPUT_FROM && isStixRefRelationship(type)) {
// If resolution is due to embedded ref, the from must be fully resolved
// This will be used to generated a correct stream message
embeddedFromResolution = id;
} else {
fetchingIds.push({ id, destKey, multiple: false });
}
expectedIds.push(id);
if (!expectedIds.includes(id)) {
expectedIds.push(id);
}
}
cleanedInput[src] = null;
}
Expand Down

0 comments on commit dd9fe4b

Please sign in to comment.