Skip to content

Commit 4189aa1

Browse files
authored
Merge pull request #1399 from credebl/develop
fix: Save schemaId during connection, email, and bulk issuance
2 parents a2e2f4b + 92238cd commit 4189aa1

File tree

4 files changed

+62
-25
lines changed

4 files changed

+62
-25
lines changed

apps/issuance/src/issuance.repository.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ export class IssuanceRepository {
230230
threadId: issueCredentialDto?.threadId,
231231
connectionId: issueCredentialDto?.connectionId,
232232
state: issueCredentialDto?.state,
233-
schemaId,
234-
credDefId
233+
credDefId,
234+
...(schemaId ? { schemaId } : {})
235235
},
236236
create: {
237237
createDateTime: issueCredentialDto?.createDateTime,
@@ -741,4 +741,18 @@ export class IssuanceRepository {
741741
throw error;
742742
}
743743
}
744+
745+
async updateSchemaIdByThreadId(threadId: string, schemaId: string): Promise<void> {
746+
try {
747+
await this.prisma.credentials.update({
748+
where: { threadId },
749+
data: {
750+
schemaId
751+
}
752+
});
753+
} catch (error) {
754+
this.logger.error(`[updateSchemaIdByThreadId] - error: ${JSON.stringify(error)}`);
755+
throw error;
756+
}
757+
}
744758
}

apps/issuance/src/issuance.service.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ export class IssuanceService {
281281

282282
if (allSuccessful) {
283283
finalStatusCode = HttpStatus.CREATED;
284+
const context = payload?.credentialData[0]?.credential?.['@context'] as string[];
285+
286+
if (Array.isArray(context) && context.includes(CommonConstants.W3C_SCHEMA_URL)) {
287+
const filterData = context.filter((item) => CommonConstants.W3C_SCHEMA_URL !== item);
288+
const [schemaId] = filterData;
289+
results.forEach((record) => {
290+
if (PromiseResult.FULFILLED === record.status && record?.value?.threadId) {
291+
this.issuanceRepository.updateSchemaIdByThreadId(record?.value?.threadId, schemaId);
292+
}
293+
});
294+
}
295+
284296
finalMessage = ResponseMessages.issuance.success.create;
285297
} else if (allFailed) {
286298
finalStatusCode = HttpStatus.BAD_REQUEST;
@@ -889,7 +901,6 @@ export class IssuanceService {
889901

890902
await this.delay(500); // Wait for 0.5 seconds
891903
const sendOobOffer = await this.sendEmailForCredentialOffer(sendEmailCredentialOffer);
892-
893904
arraycredentialOfferResponse.push(sendOobOffer);
894905
}
895906
if (0 < errors.length) {
@@ -1064,6 +1075,20 @@ export class IssuanceService {
10641075
return false;
10651076
}
10661077

1078+
if (isEmailSent) {
1079+
const w3cSchemaId = outOfBandIssuancePayload?.credentialFormats?.jsonld?.credential?.['@context'] as string[];
1080+
if (w3cSchemaId && w3cSchemaId.includes(CommonConstants.W3C_SCHEMA_URL)) {
1081+
const filterData = w3cSchemaId.filter((item) => CommonConstants.W3C_SCHEMA_URL !== item);
1082+
const [schemaId] = filterData;
1083+
if (credentialCreateOfferDetails.response.credentialRequestThId) {
1084+
this.issuanceRepository.updateSchemaIdByThreadId(
1085+
credentialCreateOfferDetails.response.credentialRequestThId,
1086+
schemaId
1087+
);
1088+
}
1089+
}
1090+
}
1091+
10671092
return isEmailSent;
10681093
} catch (error) {
10691094
const iterationNoMessage = ` at position ${iterationNo}`;

apps/organization/templates/organization-invitation.template.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
export class OrganizationInviteTemplate {
2+
public sendInviteEmailTemplate(
3+
email: string,
4+
orgName: string,
5+
orgRolesDetails: object[],
6+
firstName: string,
7+
isUserExist: boolean
8+
): string {
9+
const validUrl = isUserExist ? `${process.env.FRONT_END_URL}/sign-in` : `${process.env.FRONT_END_URL}/sign-up`;
210

3-
public sendInviteEmailTemplate(
4-
email: string,
5-
orgName: string,
6-
orgRolesDetails: object[],
7-
firstName: string,
8-
isUserExist: boolean
9-
): string {
11+
const message = isUserExist
12+
? `Please accept the invitation using the following link:`
13+
: `To get started, kindly register on ${process.env.PLATFORM_NAME} platform using this link:`;
1014

11-
const validUrl = isUserExist ? `${process.env.FRONT_END_URL}/authentication/sign-in` : `${process.env.FRONT_END_URL}/authentication/sign-up`;
15+
const secondMessage = isUserExist
16+
? `After successful login into ${process.env.PLATFORM_NAME} click on "Accept Organization Invitation" link on your dashboard.`
17+
: `After successful registration, you can log in to the platform and click on “Accept Organization Invitation” on your dashboard.`;
1218

13-
const message = isUserExist
14-
? `Please accept the invitation using the following link:`
15-
: `To get started, kindly register on ${process.env.PLATFORM_NAME} platform using this link:`;
19+
const Button = isUserExist ? `Accept Organization Invitation` : `Register on ${process.env.PLATFORM_NAME}`;
1620

17-
const secondMessage = isUserExist
18-
? `After successful login into ${process.env.PLATFORM_NAME} click on "Accept Organization Invitation" link on your dashboard.`
19-
: `After successful registration, you can log in to the platform and click on “Accept Organization Invitation” on your dashboard.`;
20-
21-
const Button = isUserExist ? `Accept Organization Invitation` : `Register on ${process.env.PLATFORM_NAME}`;
22-
2321
return `<!DOCTYPE html>
2422
<html lang="en">
2523
@@ -75,8 +73,5 @@ export class OrganizationInviteTemplate {
7573
</body>
7674
7775
</html>`;
78-
79-
}
80-
81-
82-
}
76+
}
77+
}

libs/common/src/common.constant.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export enum CommonConstants {
4545
URL_LEDG_GET_TAA = '/ledger/taa',
4646
URL_LEDG_POST_TAA_ACCEPT = '/ledger/taa/accept',
4747

48+
//W3cSCHEMA
49+
W3C_SCHEMA_URL = 'https://www.w3.org/2018/credentials/v1',
50+
4851
// MESSAGING SERVICES
4952
URL_MSG_SEND_MESSAGE = '/connections/#/send-message',
5053
URL_MSG_TRUST_PING = '/connections/#/send-ping',

0 commit comments

Comments
 (0)