diff --git a/apps/issuance/src/issuance.repository.ts b/apps/issuance/src/issuance.repository.ts index d85a9849b..7b0ea6abf 100644 --- a/apps/issuance/src/issuance.repository.ts +++ b/apps/issuance/src/issuance.repository.ts @@ -230,8 +230,8 @@ export class IssuanceRepository { threadId: issueCredentialDto?.threadId, connectionId: issueCredentialDto?.connectionId, state: issueCredentialDto?.state, - schemaId, - credDefId + credDefId, + ...(schemaId ? { schemaId } : {}) }, create: { createDateTime: issueCredentialDto?.createDateTime, @@ -741,4 +741,18 @@ export class IssuanceRepository { throw error; } } + + async updateSchemaIdByThreadId(threadId: string, schemaId: string): Promise { + try { + await this.prisma.credentials.update({ + where: { threadId }, + data: { + schemaId + } + }); + } catch (error) { + this.logger.error(`[updateSchemaIdByThreadId] - error: ${JSON.stringify(error)}`); + throw error; + } + } } diff --git a/apps/issuance/src/issuance.service.ts b/apps/issuance/src/issuance.service.ts index c315acab2..c8268baad 100644 --- a/apps/issuance/src/issuance.service.ts +++ b/apps/issuance/src/issuance.service.ts @@ -281,6 +281,18 @@ export class IssuanceService { if (allSuccessful) { finalStatusCode = HttpStatus.CREATED; + const context = payload?.credentialData[0]?.credential?.['@context'] as string[]; + + if (Array.isArray(context) && context.includes(CommonConstants.W3C_SCHEMA_URL)) { + const filterData = context.filter((item) => CommonConstants.W3C_SCHEMA_URL !== item); + const [schemaId] = filterData; + results.forEach((record) => { + if (PromiseResult.FULFILLED === record.status && record?.value?.threadId) { + this.issuanceRepository.updateSchemaIdByThreadId(record?.value?.threadId, schemaId); + } + }); + } + finalMessage = ResponseMessages.issuance.success.create; } else if (allFailed) { finalStatusCode = HttpStatus.BAD_REQUEST; @@ -889,7 +901,6 @@ export class IssuanceService { await this.delay(500); // Wait for 0.5 seconds const sendOobOffer = await this.sendEmailForCredentialOffer(sendEmailCredentialOffer); - arraycredentialOfferResponse.push(sendOobOffer); } if (0 < errors.length) { @@ -1064,6 +1075,20 @@ export class IssuanceService { return false; } + if (isEmailSent) { + const w3cSchemaId = outOfBandIssuancePayload?.credentialFormats?.jsonld?.credential?.['@context'] as string[]; + if (w3cSchemaId && w3cSchemaId.includes(CommonConstants.W3C_SCHEMA_URL)) { + const filterData = w3cSchemaId.filter((item) => CommonConstants.W3C_SCHEMA_URL !== item); + const [schemaId] = filterData; + if (credentialCreateOfferDetails.response.credentialRequestThId) { + this.issuanceRepository.updateSchemaIdByThreadId( + credentialCreateOfferDetails.response.credentialRequestThId, + schemaId + ); + } + } + } + return isEmailSent; } catch (error) { const iterationNoMessage = ` at position ${iterationNo}`; diff --git a/apps/organization/templates/organization-invitation.template.ts b/apps/organization/templates/organization-invitation.template.ts index e3fb38f58..b40a05ab8 100644 --- a/apps/organization/templates/organization-invitation.template.ts +++ b/apps/organization/templates/organization-invitation.template.ts @@ -1,25 +1,23 @@ export class OrganizationInviteTemplate { + public sendInviteEmailTemplate( + email: string, + orgName: string, + orgRolesDetails: object[], + firstName: string, + isUserExist: boolean + ): string { + const validUrl = isUserExist ? `${process.env.FRONT_END_URL}/sign-in` : `${process.env.FRONT_END_URL}/sign-up`; - public sendInviteEmailTemplate( - email: string, - orgName: string, - orgRolesDetails: object[], - firstName: string, - isUserExist: boolean - ): string { + const message = isUserExist + ? `Please accept the invitation using the following link:` + : `To get started, kindly register on ${process.env.PLATFORM_NAME} platform using this link:`; - const validUrl = isUserExist ? `${process.env.FRONT_END_URL}/authentication/sign-in` : `${process.env.FRONT_END_URL}/authentication/sign-up`; + const secondMessage = isUserExist + ? `After successful login into ${process.env.PLATFORM_NAME} click on "Accept Organization Invitation" link on your dashboard.` + : `After successful registration, you can log in to the platform and click on “Accept Organization Invitation” on your dashboard.`; - const message = isUserExist - ? `Please accept the invitation using the following link:` - : `To get started, kindly register on ${process.env.PLATFORM_NAME} platform using this link:`; + const Button = isUserExist ? `Accept Organization Invitation` : `Register on ${process.env.PLATFORM_NAME}`; - const secondMessage = isUserExist - ? `After successful login into ${process.env.PLATFORM_NAME} click on "Accept Organization Invitation" link on your dashboard.` - : `After successful registration, you can log in to the platform and click on “Accept Organization Invitation” on your dashboard.`; - - const Button = isUserExist ? `Accept Organization Invitation` : `Register on ${process.env.PLATFORM_NAME}`; - return ` @@ -75,8 +73,5 @@ export class OrganizationInviteTemplate { `; - - } - - -} \ No newline at end of file + } +} diff --git a/libs/common/src/common.constant.ts b/libs/common/src/common.constant.ts index dd282e009..734c88f77 100644 --- a/libs/common/src/common.constant.ts +++ b/libs/common/src/common.constant.ts @@ -45,6 +45,9 @@ export enum CommonConstants { URL_LEDG_GET_TAA = '/ledger/taa', URL_LEDG_POST_TAA_ACCEPT = '/ledger/taa/accept', + //W3cSCHEMA + W3C_SCHEMA_URL = 'https://www.w3.org/2018/credentials/v1', + // MESSAGING SERVICES URL_MSG_SEND_MESSAGE = '/connections/#/send-message', URL_MSG_TRUST_PING = '/connections/#/send-ping',