Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 24 additions & 29 deletions apps/connection/src/connection.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class ConnectionRepository {
}
}


async getConnectionRecordsCount(orgId: string): Promise<number> {
try {
const connectionRecordsCount = await this.prisma.connections.count({
Expand All @@ -105,7 +104,6 @@ export class ConnectionRepository {
}
}


/**
* Description: Save connection details
* @param connectionInvitation
Expand Down Expand Up @@ -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}`;
Expand All @@ -343,45 +341,42 @@ 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}`);
throw error;
}
}

// eslint-disable-next-line camelcase
async getInvitationDidByOrgId(orgId: string): Promise<agent_invitations[]> {
// eslint-disable-next-line camelcase
async getInvitationDidByOrgId(orgId: string): Promise<agent_invitations> {
try {
return this.prisma.agent_invitations.findMany({
return this.prisma.agent_invitations.findFirst({
where: {
orgId
},
Expand Down
17 changes: 6 additions & 11 deletions apps/connection/src/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,21 +528,16 @@ export class ConnectionService {
throw new NotFoundException(ResponseMessages.connection.error.agentEndPointNotFound);
}

let legacyinvitationDid;
let legacyInvitationDid;
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 ? 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,
Expand Down