Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion src/app-auth/repositories/app.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export class AppRepository {
try {
Logger.log('findAndDeleteServiceDB() method to delte service database');
// Establish a connection to the MongoDB server
const mainConnection = await mongoose.connect(process.env.DB_BASE_PATH);
const databaseUri = this.config.get<string>('DATABASE_CONNECTION_PATH');
const baseUri = databaseUri.replace(
/(mongodb\+srv:\/\/[^\/]+)\/[^?]+/,
'$1',
);
const mainConnection = await mongoose.connect(baseUri);
// Switch to the target database
const dbConnection = mainConnection.connection.useDb(
connectionStringPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class CustomerOnboardingController {
}
return this.customerOnboardingService.createCustomerOnboardingDetail(
createCustomerOnboardingDto,
req.user['userId'],
req.user,
req.user['email'],
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import {
BusinessField,
CountryCode,

Check warning on line 4 in src/customer-onboarding/schemas/customer-onboarding.schema.ts

View workflow job for this annotation

GitHub Actions / build

'CountryCode' is defined but never used
CreditStatus,
CustomerType,
InterestedService,
Expand Down Expand Up @@ -75,7 +75,7 @@
ssiServiceId?: string;
@Prop({ type: String, required: false })
kycServiceId?: string;
@Prop({ type: String, required: true, unique: true })
@Prop({ type: String, required: true })
userId: string;
}

Expand Down
20 changes: 16 additions & 4 deletions src/customer-onboarding/services/customer-onboarding.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
} from 'src/webpage-config/dto/create-webpage-config.dto';
import getOnboardingRetryNotificationMail from 'src/mail-notification/constants/templates/request-retry-onboarding';
import { redisClient } from 'src/utils/redis.provider';
import { EXPIRY_CONFIG, TIME } from 'src/utils/time-constant';

Check warning on line 56 in src/customer-onboarding/services/customer-onboarding.service.ts

View workflow job for this annotation

GitHub Actions / build

'TIME' is defined but never used
import { TokenModule } from 'src/config/access-matrix';
import { AuthzCreditService } from 'src/credits/services/credits.service';
import { urlSanitizer } from 'src/utils/sanitizeUrl.validator';
Expand Down Expand Up @@ -82,16 +82,25 @@
*/
async createCustomerOnboardingDetail(
createCustomerOnboardingDto: CreateCustomerOnboardingDto,
userId: string,
user,
loggedInUserEmail,
) {
try {
if (user.role === UserRole.ADMIN) {
const existingOnboarding =
await this.customerOnboardingRepository.findCustomerOnboardingById({
userId: user.userId,
});
if (existingOnboarding) {
throw new ConflictException['You can only create onboarding once']();
}
}
const { interestedService, companyName, twitterUrl, telegramUrl, type } =
createCustomerOnboardingDto;
const onboardingData =
await this.customerOnboardingRepository.createCustomerOnboarding({
...createCustomerOnboardingDto,
userId,
userId: user.userId,
});
const requestedServices =
interestedService.length === 1
Expand All @@ -100,12 +109,12 @@
const { customerEmail } = createCustomerOnboardingDto;

const message = getCreditRequestNotificationMail(
userId,
user.userId,
customerEmail,
requestedServices,
onboardingData['_id'].toString(),
companyName,
type,
String(type),
loggedInUserEmail,
twitterUrl,
telegramUrl,
Expand Down Expand Up @@ -1027,6 +1036,9 @@
const userOnboardingDetail =
await this.customerOnboardingRepository.findCustomerOnboardingById({
userId: user.userId,
sort: {
createdAt: -1,
},
});
if (!userOnboardingDetail) {
throw new BadRequestException([
Expand Down
15 changes: 8 additions & 7 deletions src/mail-notification/constants/element/body.template.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export default function getBody(container): string {
return `
<body class="clean-body u_body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #e7e7e7;color: #000000">
<!--[if IE]><div class="ie-container"><![endif]-->
<!--[if mso]><div class="mso-container"><![endif]-->
${container}
</body>
`;
return `<body class="clean-body u_body"
style="margin:0; padding:0; -webkit-text-size-adjust:100%; background-color:#F9FAFB; color:#374151;">
<!--[if IE]><div class="ie-container"><![endif]-->
<!--[if mso]><div class="mso-container"><![endif]-->
${container}
<!--[if IE]></div><![endif]-->
<!--[if mso]></div><![endif]-->
</body>`;
}
105 changes: 63 additions & 42 deletions src/mail-notification/constants/element/container.template.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,70 @@
import { footer } from './footer.template';
import { getSalutation, header } from './header.template';
import { getHeader, getSalutation } from './header.template';
import { signature } from './signature.template';

export function getContainer(
messageTemplate: string,
salutationMessage = 'KYC Approved',
): string {
return `
<table id="u_body"
style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #e7e7e7;width:100%"
cellpadding="0" cellspacing="0">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top">
${header}
${getSalutation(salutationMessage)}

<div class="u-row-container" style="padding: 0px;background-color: white">
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: white;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: white;">
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div style="line-height: 140%; text-align: left; word-wrap: break-word;">
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td class="v-container-padding-padding" style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
${messageTemplate}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
${signature}
</td>
</tr>
<tr>
<td>
${footer}
</td>
</tr>
</tbody>
</table>
`;
return `<!-- Outer background -->
<table id="u_body" role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"
style="border-collapse:collapse; background-color:#F9FAFB; width:100%;">
<tr>
<td align="center" style="padding:36px 16px 48px;">

<!-- Email card -->
<table class="email-card" role="presentation" cellpadding="0" cellspacing="0" border="0"
style="width:600px; max-width:100%; background-color:#FFFFFF;
border-radius:16px; overflow:hidden;
box-shadow:0 4px 40px rgba(0,0,0,0.10);">

${getHeader(salutationMessage)}
${getSalutation(salutationMessage)}

<!-- Body content -->
<tr>
<td class="content-td"
style="padding:36px 40px; font-family:Arial,Helvetica,sans-serif;
font-size:15px; line-height:1.75; color:#374151;
background-color:#FFFFFF;">
${messageTemplate}
</td>
</tr>

${signature}
${footer}

</table>

<!-- Below-card: social + tagline -->
<table role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" style="margin:20px auto 0;">
<tr>
<td style="padding:0 8px;">
<a href="https://www.linkedin.com/company/hypersign-id/" target="_blank" rel="noopener"
style="text-decoration:none; display:inline-block;">
<img src="https://img.icons8.com/ios-filled/48/888888/linkedin.png"
alt="LinkedIn" width="24" height="24"
style="display:block; border:0;" />
</a>
</td>
<td style="padding:0 8px;">
<a href="https://x.com/hypersignchain" target="_blank" rel="noopener"
style="text-decoration:none; display:inline-block;">
<img src="https://img.icons8.com/ios-filled/48/888888/twitterx--v1.png"
alt="X / Twitter" width="24" height="24"
style="display:block; border:0;" />
</a>
</td>
</tr>
</table>
<p style="font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#6B7280;
text-align:center; margin:12px 0 0; line-height:1.8; max-width:400px;
margin-left:auto; margin-right:auto; font-weight:500; letter-spacing:0.1px;">
Hypersign helps Web3 and fintech companies prevent fraud and reduce<br>
KYC friction with reusable identity.
</p>

</td>
</tr>
</table>`;
}
22 changes: 8 additions & 14 deletions src/mail-notification/constants/element/footer.template.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
export const footer = `
<div style="font-family:Helvetica,Arial,sans-serif;font-size:12px;background-color: #1b1c28;text-align:center">
<br>
<p style="font-size: 14px; line-height: 140%; text-align: center;">
<span style=" font-size: 14px; line-height: 19.6px;">
<a rel="noopener" href="https://hypersign.id/" target="_blank"><span>Website |</span></a>
<a rel="noopener" href="https://docs.hypersign.id/" target="_blank">Docs |</a>
<a rel="noopener" href="mailto:noreply@hypersign.id" target="_blank">Support</a>
</span>
export const footer = `<tr>
<td class="footer-td" align="center"
style="padding:16px 40px 20px; background-color:#FFFFFF;
border-top:1px solid #F3F4F6; font-family:Arial,Helvetica,sans-serif;">
<p style="font-size:11px; color:#D1D5DB; margin:0; line-height:1.6;">
&copy; ${new Date().getFullYear()} Hypersign &mdash; All rights reserved
</p>
<br>
<p style="color:#AEAEAE"> Hypermine Ltd, Bengaluru, 560001</p>
<br>
</div>
`;
</td>
</tr>`;
112 changes: 30 additions & 82 deletions src/mail-notification/constants/element/header.template.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,33 @@
export const header = `
<div class="u-row-container" style="padding: 0px;background-color: white">
<div class="u-row"
style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: white;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: white;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: white;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: white;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid white;border-left: 0px solid white;border-right: 0px solid white;border-bottom: 0px solid white;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="height: 100%; padding: 0px;border-top: 0px solid white;border-left: 0px solid white;border-right: 0px solid white;border-bottom: 0px solid white;">
<!--<![endif]-->

<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0"
cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td class="v-container-padding-padding"
style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif; text-align: center"
align="left">
</td>
</tr>
</tbody>
</table>
import { getContainer } from './container.template';

const LOGO_URL =
'https://storage.googleapis.com/fyre-image-storage/download.png';

export function getHeader(_salutationMessage: string): string {
return `<tr>
<td class="header-td" align="center"
style="background-color:#FFFFFF; padding:20px 40px; text-align:center; border-bottom:1px solid #E5E7EB;">
<a href="https://hypersign.id" target="_blank"
style="text-decoration:none; display:inline-block; line-height:1;">
<img
src="${LOGO_URL}"
alt="Hypersign"
width="150"
style="display:block; border:0; max-width:150px; height:auto; width:150px;" />
</a>
</td>
</tr>`;
}

<!--[if (!mso)&(!IE)]><!-->
</div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
`;
export function getSalutation(statusMessage = 'KYC Verified'): string {
return `
<div class="u-row-container" style="padding: 0px;background-color: white">
<div class="u-row"
style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: white;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: white;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: white;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: white;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid white;border-left: 0px solid white;border-right: 0px solid white;border-bottom: 0px solid white;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div
style="height: 100%;width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="height: 100%; padding: 0px;border-top: 0px solid white;border-left: 0px solid white;border-right: 0px solid white;border-bottom: 0px solid white;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
<!--<![endif]-->

<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0"
cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td class="v-container-padding-padding"
style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;"
align="left">

<div style="line-height: 140%; text-align: left; word-wrap: break-word;">
<h1>${statusMessage}</h1>
<p style="font-size: 14px; line-height: 140%;">HeyπŸ‘‹,</p>
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
`;
return `<tr>
<td style="padding:32px 40px 0; background-color:#FFFFFF;
font-family:Arial,Helvetica,sans-serif;">
<h1 class="status-h1"
style="font-size:22px; font-weight:700; color:#6B7280;
margin:0 0 4px; line-height:1.3;">
${statusMessage}
</h1>
</td>
</tr>`;
}
36 changes: 12 additions & 24 deletions src/mail-notification/constants/element/signature.template.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
export const signature = `
<div class="u-row-container" style="padding: 0px;background-color: white">
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: white;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: white;">
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div style="line-height: 140%; text-align: left; word-wrap: break-word;">
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td class="v-container-padding-padding" style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
Thanks & Regards,
<br>
Team Hypersign
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
`;
export const signature = `<tr>
<td class="sig-td"
style="padding:24px 40px; border-top:1px solid #E5E7EB; background-color:#FFFFFF;
font-family:Arial,Helvetica,sans-serif;">
<p style="font-size:14px; color:#6B7280; margin:0 0 4px; line-height:1.6;">
Warm regards,
</p>
<p style="font-size:15px; font-weight:700; color:#111827; margin:0; line-height:1.6;">
Team Hypersign
</p>
</td>
</tr>`;
Loading
Loading