From f341285563905370e9bd5285806313597c151d11 Mon Sep 17 00:00:00 2001 From: Nishad Date: Thu, 14 Dec 2023 12:17:05 +0530 Subject: [PATCH 1/3] worked on the ecosystem invitation reject Signed-off-by: Nishad --- apps/ecosystem/src/ecosystem.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index d48fe8b46..de134bf3c 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -120,7 +120,7 @@ export class EcosystemService { if (tags) { updateData.tags = tags; } - if (logo) { updateData.logo = tags; } + if (logo) { updateData.logo = logo; } if ('' !== autoEndorsement.toString()) { updateData.autoEndorsement = autoEndorsement; } @@ -350,7 +350,7 @@ export class EcosystemService { } } - if (!isLedgerFound) { + if (!isLedgerFound && status !== Invitation.REJECTED) { throw new NotFoundException(ResponseMessages.ecosystem.error.ledgerNotMatch); } From 60b9a23fd9f7668e9065af287a09468086591edc Mon Sep 17 00:00:00 2001 From: Nishad Date: Thu, 14 Dec 2023 15:22:32 +0530 Subject: [PATCH 2/3] worked on the ledger details match function Signed-off-by: Nishad --- apps/ecosystem/src/ecosystem.service.ts | 32 +++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index de134bf3c..15b81142a 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -301,6 +301,24 @@ export class EcosystemService { } } + async checkLedgerMatches(orgDetails: OrganizationData, ecosystemId: string): Promise { + const orgLedgers = orgDetails.org_agents.map((agent) => agent.ledgers.id); + + const ecosystemDetails = await this.ecosystemRepository.getEcosystemDetails(ecosystemId); + + let isLedgerFound = false; + + for (const ledger of orgLedgers) { + // Check if the ledger is present in the ecosystem + if (Array.isArray(ecosystemDetails.ledgers) && ecosystemDetails.ledgers.includes(ledger)) { + // If a ledger is found, return true + isLedgerFound = true; + } + } + + return isLedgerFound; + } + /** * * @param acceptRejectEcosystemInvitation @@ -336,19 +354,7 @@ export class EcosystemService { throw new NotFoundException(ResponseMessages.ecosystem.error.orgDidNotExist); } - const orgLedgers = orgDetails.org_agents.map((agent) => agent.ledgers.id); - - const ecosystemDetails = await this.ecosystemRepository.getEcosystemDetails(invitation.ecosystemId); - - let isLedgerFound = false; - - for (const ledger of orgLedgers) { - // Check if the ledger is present in the ecosystem - if (Array.isArray(ecosystemDetails.ledgers) && ecosystemDetails.ledgers.includes(ledger)) { - // If a ledger is found, return true - isLedgerFound = true; - } - } + const isLedgerFound = await this.checkLedgerMatches(orgDetails, invitation.ecosystemId); if (!isLedgerFound && status !== Invitation.REJECTED) { throw new NotFoundException(ResponseMessages.ecosystem.error.ledgerNotMatch); From 425cd9aa35fa19cfff4b4f57f1637d26e70d222c Mon Sep 17 00:00:00 2001 From: Nishad Date: Thu, 14 Dec 2023 15:38:37 +0530 Subject: [PATCH 3/3] cosmetic changes Signed-off-by: Nishad --- apps/ecosystem/src/ecosystem.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index 15b81142a..099a45aef 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -356,7 +356,7 @@ export class EcosystemService { const isLedgerFound = await this.checkLedgerMatches(orgDetails, invitation.ecosystemId); - if (!isLedgerFound && status !== Invitation.REJECTED) { + if (!isLedgerFound && Invitation.REJECTED !== status) { throw new NotFoundException(ResponseMessages.ecosystem.error.ledgerNotMatch); }