From 4e6477297e47e3030a85b0a1bfcba41f67a1bcd2 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Thu, 19 Sep 2024 19:07:54 +0530 Subject: [PATCH] refactor: provide appName --- apps/OpenSignServer/Utils.js | 1 + .../cloud/parsefunction/SendMailOTPv1.js | 8 ++++---- apps/OpenSignServer/files/verification_email.html | 2 +- .../files/verification_email_subject.txt | 2 +- apps/OpenSignServer/index.js | 13 ++++--------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/apps/OpenSignServer/Utils.js b/apps/OpenSignServer/Utils.js index 69fc77b84..a721fff43 100644 --- a/apps/OpenSignServer/Utils.js +++ b/apps/OpenSignServer/Utils.js @@ -2,6 +2,7 @@ import dotenv from 'dotenv'; dotenv.config(); export const cloudServerUrl = 'http://localhost:8080/app'; +export const appName = process.env.APP_NAME || 'OpenSign™'; export function customAPIurl() { const url = new URL(cloudServerUrl); return url.pathname === '/api/app' ? url.origin + '/api' : url.origin; diff --git a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js index e400fdf58..3de9b0c2d 100644 --- a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js +++ b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js @@ -1,4 +1,4 @@ -import { smtpenable, updateMailCount } from '../../Utils.js'; +import { appName, smtpenable, updateMailCount } from '../../Utils.js'; async function getDocument(docId) { try { const query = new Parse.Query('contracts_Document'); @@ -28,12 +28,12 @@ async function sendMailOTPv1(request) { const mailsender = smtpenable ? process.env.SMTP_USER_EMAIL : process.env.MAILGUN_SENDER; try { await Parse.Cloud.sendEmail({ - from: 'Opensign™' + ' <' + mailsender + '>', + from: appName + ' <' + mailsender + '>', recipient: recipient, - subject: 'Your OpenSign™ OTP', + subject: `Your ${appName} OTP`, text: 'This email is a test.', html: - "

OTP Verification

Your OTP for OpenSign™ verification is:

" + + `

OTP Verification

Your OTP for ${appName} verification is:

` + code + '

', }); diff --git a/apps/OpenSignServer/files/verification_email.html b/apps/OpenSignServer/files/verification_email.html index 2cae33453..dfc5e0b1f 100644 --- a/apps/OpenSignServer/files/verification_email.html +++ b/apps/OpenSignServer/files/verification_email.html @@ -10,7 +10,7 @@

Verify email


-

OpenSign™

+

{{appName}}

diff --git a/apps/OpenSignServer/files/verification_email_subject.txt b/apps/OpenSignServer/files/verification_email_subject.txt index 0f8684f2f..7300c522a 100644 --- a/apps/OpenSignServer/files/verification_email_subject.txt +++ b/apps/OpenSignServer/files/verification_email_subject.txt @@ -1 +1 @@ -OpenSign™ Email Address Verification \ No newline at end of file +{{appName}} Email Address Verification \ No newline at end of file diff --git a/apps/OpenSignServer/index.js b/apps/OpenSignServer/index.js index 8634a231c..88569decf 100644 --- a/apps/OpenSignServer/index.js +++ b/apps/OpenSignServer/index.js @@ -17,7 +17,7 @@ import { exec } from 'child_process'; import { createTransport } from 'nodemailer'; import { app as v1 } from './cloud/customRoute/v1/apiV1.js'; import { PostHog } from 'posthog-node'; -import { cloudServerUrl, smtpenable, smtpsecure, useLocal } from './Utils.js'; +import { appName, cloudServerUrl, smtpenable, smtpsecure, useLocal } from './Utils.js'; import { SSOAuth } from './auth/authadapter.js'; let fsAdapter; if (useLocal !== 'true') { @@ -102,7 +102,7 @@ export const config = { verifyUserEmails: false, publicServerURL: process.env.SERVER_URL || cloudServerUrl, // Your apps name. This will appear in the subject and body of the emails that are sent. - appName: 'Opensign', + appName: appName, allowClientClassCreation: false, allowExpiredAuthDataToken: false, encodeParseObjectInCloudFunction: true, @@ -112,7 +112,7 @@ export const config = { module: 'parse-server-api-mail-adapter', options: { // The email address from which emails are sent. - sender: 'Opensign™' + ' <' + mailsender + '>', + sender: appName + ' <' + mailsender + '>', // The email templates. templates: { // The template used by Parse Server to send an email for password @@ -141,12 +141,7 @@ export const config = { } : {}), filesAdapter: fsAdapter, - auth: { - google: { - enabled: true, - }, - sso: SSOAuth, - }, + auth: { google: { enabled: true }, sso: SSOAuth }, }; // Client-keys like the javascript key or the .NET key are not necessary with parse-server // If you wish you require them, you can set them as options in the initialization above: