Skip to content
18 changes: 16 additions & 2 deletions apps/issuance/src/issuance.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -741,4 +741,18 @@ export class IssuanceRepository {
throw error;
}
}

async updateSchemaIdByThreadId(threadId: string, schemaId: string): Promise<void> {
try {
await this.prisma.credentials.update({
where: { threadId },
data: {
schemaId
}
});
} catch (error) {
this.logger.error(`[updateSchemaIdByThreadId] - error: ${JSON.stringify(error)}`);
throw error;
}
}
}
27 changes: 26 additions & 1 deletion apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`;
Expand Down
39 changes: 17 additions & 22 deletions apps/organization/templates/organization-invitation.template.ts
Original file line number Diff line number Diff line change
@@ -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 `<!DOCTYPE html>
<html lang="en">

Expand Down Expand Up @@ -75,8 +73,5 @@ export class OrganizationInviteTemplate {
</body>

</html>`;

}


}
}
}
3 changes: 3 additions & 0 deletions libs/common/src/common.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down