diff --git a/apps/connection/src/connection.repository.ts b/apps/connection/src/connection.repository.ts index ec43c8385..474993b43 100644 --- a/apps/connection/src/connection.repository.ts +++ b/apps/connection/src/connection.repository.ts @@ -90,7 +90,6 @@ export class ConnectionRepository { } } - async getConnectionRecordsCount(orgId: string): Promise { try { const connectionRecordsCount = await this.prisma.connections.count({ @@ -105,7 +104,6 @@ export class ConnectionRepository { } } - /** * Description: Save connection details * @param connectionInvitation @@ -333,7 +331,7 @@ export class ConnectionRepository { if (0 < referencedTables.length) { let errorMessage = `Organization ID ${orgId} is referenced in the following table(s): ${referencedTables.join(', ')}`; - + if (1 === referencedTables.length) { if (referencedTables.includes(`${PrismaTables.PRESENTATIONS}`)) { errorMessage += `, ${ResponseMessages.verification.error.removeVerificationData}`; @@ -343,34 +341,31 @@ export class ConnectionRepository { } else if (2 === referencedTables.length) { errorMessage += `, ${ResponseMessages.connection.error.removeConnectionReferences}`; } - + throw new ConflictException(errorMessage); } - - const getConnectionRecords = await prisma.connections.findMany( - { - where: { - orgId - }, - select: { - createDateTime: true, - createdBy: true, - connectionId: true, - theirLabel: true, - state: true, - orgId: true - } - }); + const getConnectionRecords = await prisma.connections.findMany({ + where: { + orgId + }, + select: { + createDateTime: true, + createdBy: true, + connectionId: true, + theirLabel: true, + state: true, + orgId: true + } + }); - const deleteConnectionRecords = await prisma.connections.deleteMany( - { - where: { - orgId - } - }); + const deleteConnectionRecords = await prisma.connections.deleteMany({ + where: { + orgId + } + }); - return {getConnectionRecords, deleteConnectionRecords }; + return { getConnectionRecords, deleteConnectionRecords }; }); } catch (error) { this.logger.error(`Error in deleting connection records: ${error.message}`); @@ -378,10 +373,10 @@ export class ConnectionRepository { } } - // eslint-disable-next-line camelcase - async getInvitationDidByOrgId(orgId: string): Promise { + // eslint-disable-next-line camelcase + async getInvitationDidByOrgId(orgId: string): Promise { try { - return this.prisma.agent_invitations.findMany({ + return this.prisma.agent_invitations.findFirst({ where: { orgId }, diff --git a/apps/connection/src/connection.service.ts b/apps/connection/src/connection.service.ts index 8442c7421..431699b11 100644 --- a/apps/connection/src/connection.service.ts +++ b/apps/connection/src/connection.service.ts @@ -528,21 +528,16 @@ export class ConnectionService { throw new NotFoundException(ResponseMessages.connection.error.agentEndPointNotFound); } - let legacyinvitationDid; + let legacyInvitationDid: string | undefined; if (IsReuseConnection) { - const data: agent_invitations[] = await this.connectionRepository.getInvitationDidByOrgId(orgId); - if (data && 0 < data.length) { - const [firstElement] = data; - legacyinvitationDid = firstElement?.invitationDid ?? undefined; - - this.logger.log('legacyinvitationDid:', legacyinvitationDid); - } + const data: agent_invitations = await this.connectionRepository.getInvitationDidByOrgId(orgId); + legacyInvitationDid = data?.invitationDid ?? undefined; } - const connectionInvitationDid = invitationDid ? invitationDid : legacyinvitationDid; + const connectionInvitationDid = invitationDid ?? legacyInvitationDid; - this.logger.log('connectionInvitationDid:', connectionInvitationDid); + this.logger.debug('connectionInvitationDid:', connectionInvitationDid); - this.logger.log(`logoUrl:::, ${organisation.logoUrl}`); + this.logger.debug(`logoUrl:::, ${organisation.logoUrl}`); const connectionPayload = { multiUseInvitation: multiUseInvitation ?? true, autoAcceptConnection: autoAcceptConnection ?? true,