Skip to content

Commit 14ecbaf

Browse files
authored
Merge pull request #516 from samwel141/master
Correct exclude_managed parameter handling in trust relationships
2 parents 67b9a5a + 6803912 commit 14ecbaf

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

server/models/Trust.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,17 @@ class Trust {
108108
);
109109

110110
if (exclude_managed) {
111-
result.result = result.result.filter(relationship =>
112-
relationship.request_type !== 'manage' &&
113-
relationship.request_type !== 'yield'
114-
);
111+
const managedWalletIdSet = new Set(managedWallets.map((wallet) => wallet.id));
112+
113+
result.result = result.result.filter(relationship => {
114+
const actorIsManaged = managedWalletIdSet.has(relationship.actor_wallet_id);
115+
const targetIsManaged = managedWalletIdSet.has(relationship.target_wallet_id);
116+
117+
const isBothManagedInternal = actorIsManaged && targetIsManaged;
118+
119+
return !isBothManagedInternal;
120+
});
121+
115122
result.count = result.result.length;
116123
}
117124

0 commit comments

Comments
 (0)