emails - cleanup old stuff
MODIFY
package-lock.json
package-lock.json
"csvtojson": "^2.0.10",
"curvereduce": "^0.0.4",
"decimal.js": "^10.3.1",
- "ejs": "^3.1.8",
"emailjs": "3.8.0",
"express": "^4.18.1",
"express-sanitizer": "^1.0.6",
"node_modules/async": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz",
- "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
+ "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==",
+ "dev": true
},
"node_modules/async-retry": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
- "node_modules/ejs": {
- "version": "3.1.8",
- "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
- "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
- "dependencies": {
- "jake": "^10.8.5"
- },
- "bin": {
- "ejs": "bin/cli.js"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/electron-to-chromium": {
"version": "1.3.892",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.892.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true
},
- "node_modules/filelist": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
- "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
- "dependencies": {
- "minimatch": "^5.0.1"
- }
- },
- "node_modules/filelist/node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dependencies": {
- "balanced-match": "^1.0.0"
- }
- },
- "node_modules/filelist/node_modules/minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
- "dependencies": {
- "brace-expansion": "^2.0.1"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"node": ">=8"
}
},
- "node_modules/jake": {
- "version": "10.8.5",
- "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz",
- "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==",
- "dependencies": {
- "async": "^3.2.3",
- "chalk": "^4.0.2",
- "filelist": "^1.0.1",
- "minimatch": "^3.0.4"
- },
- "bin": {
- "jake": "bin/cli.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/jest": {
"version": "29.1.2",
"resolved": "https://registry.npmjs.org/jest/-/jest-29.1.2.tgz",
"async": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz",
- "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
+ "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==",
+ "dev": true
},
"async-retry": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
- "ejs": {
- "version": "3.1.8",
- "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
- "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
- "requires": {
- "jake": "^10.8.5"
- }
- },
"electron-to-chromium": {
"version": "1.3.892",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.892.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true
},
- "filelist": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
- "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
- "requires": {
- "minimatch": "^5.0.1"
- },
- "dependencies": {
- "brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "requires": {
- "balanced-match": "^1.0.0"
- }
- },
- "minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
- "requires": {
- "brace-expansion": "^2.0.1"
- }
- }
- }
- },
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"istanbul-lib-report": "^3.0.0"
}
},
- "jake": {
- "version": "10.8.5",
- "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz",
- "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==",
- "requires": {
- "async": "^3.2.3",
- "chalk": "^4.0.2",
- "filelist": "^1.0.1",
- "minimatch": "^3.0.4"
- }
- },
"jest": {
"version": "29.1.2",
"resolved": "https://registry.npmjs.org/jest/-/jest-29.1.2.tgz",

MODIFY
package.json
package.json
"csvtojson": "^2.0.10",
"curvereduce": "^0.0.4",
"decimal.js": "^10.3.1",
- "ejs": "^3.1.8",
"emailjs": "3.8.0",
"express": "^4.18.1",
"express-sanitizer": "^1.0.6",

MODIFY
src/notification/email/EMailNotificationTask.ts
src/notification/email/EMailNotificationTask.ts
/* eslint-disable max-len */
import { AccountVerificationNotification, AdminAccountVerificationNotification, BillingAccountActivationNotification, BillingAccountCreationLinkNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EmailNotificationMessage, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, NotificationResult, NotificationSeverity, OCPIPatchChargingStationsStatusesErrorNotification, OICPPatchChargingStationsErrorNotification, OICPPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, UserCreatePassword, VerificationEmailNotification } from '../../types/UserNotifications';
import EmailComponentManager, { EmailComponent } from './EmailComponentManager';
-import FeatureToggles, { Feature } from '../../utils/FeatureToggles';
import { Message, SMTPClient, SMTPError } from 'emailjs';
import BackendError from '../../exception/BackendError';
@@ -14,14 +13,10 @@ import Logging from '../../utils/Logging';
import LoggingHelper from '../../utils/LoggingHelper';
import NotificationTask from '../NotificationTask';
import { ServerAction } from '../../types/Server';
-import TemplateManager from '../../utils/TemplateManager';
import Tenant from '../../types/Tenant';
import TenantStorage from '../../storage/mongodb/TenantStorage';
import User from '../../types/User';
import Utils from '../../utils/Utils';
-import ejs from 'ejs';
-import fs from 'fs';
-import global from '../../types/GlobalType';
import mjmlBuilder from './EmailMjmlBuilder';
import rfc2047 from 'rfc2047';

MODIFY
src/utils/FeatureToggles.ts
src/utils/FeatureToggles.ts
export enum Feature {
BILLING_PREVENT_CUSTOMER_DELETION,
BILLING_SHOW_PRICING_DETAIL,
- // NEW_EMAIL_TEMPLATES,
}
export default class FeatureToggles {
// Comment out the features that you want to switch OFF
private static activeFeatures: Feature[] = [
Feature.BILLING_PREVENT_CUSTOMER_DELETION,
- // Feature.NEW_EMAIL_TEMPLATES,
- // Feature.BILLING_SHOW_PRICING_DETAIL,
];
// Check whether the feature is active or not!

DELETE
src/utils/TemplateManager.ts
-import Constants from './Constants';
-import Utils from './Utils';
-import { promises as fs } from 'fs';
-import global from '../types/GlobalType';
-
-export default class TemplateManager {
- private static instances = new Map<string, TemplateManager>();
- private language: string;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- private parsedTemplates = new Map<string, any>();
-
- private constructor(locale: string) {
- // Get language
- this.language = Utils.getLanguageFromLocale(locale);
- // Supported languages?
- if (!this.language || !Constants.SUPPORTED_LANGUAGES.includes(this.language)) {
- // Default
- this.language = Constants.DEFAULT_LANGUAGE;
- }
- }
-
- // Get a template manager instance for a particular locale
- public static getInstanceForLocale(locale: string = Constants.DEFAULT_LOCALE): TemplateManager {
- let templateManager = TemplateManager.instances.get(locale);
- if (!templateManager) {
- templateManager = new TemplateManager(locale);
- TemplateManager.instances.set(locale, templateManager);
- }
- return templateManager;
- }
-
- // Get the template from the cache or load it
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- public async getTemplate(templateName: string) : Promise<any> {
- let parsedTemplate = this.parsedTemplates.get(templateName);
- if (!parsedTemplate) {
- parsedTemplate = await this.loadTemplateAndParse(templateName);
- this.parsedTemplates.set(templateName, parsedTemplate);
- }
- // Very important here - Make sure to return a clone!
- return Utils.cloneObject(parsedTemplate);
- }
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- public async loadTemplateAndParse(templateName: string) : Promise<any> {
- try {
- const fileName = `${global.appRoot}/assets/server/notification/email/${this.language}/${templateName}.json`;
- const content = await fs.readFile(fileName, 'utf8');
- const parsedContent = JSON.parse(content);
- return parsedContent;
- } catch (error) {
- // Do not log that one - an exception is thrown by the caller when null is returned
- }
- return null;
- }
-}

emails - cleanup old stuff