Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

chore: refactor notification email template loading

towfiqi11e96ebcaf51
diff --git a/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts b/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts
index fe005f6..07b55a6 100644
--- a/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts
+++ b/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts
@@ -82,6 +82,10 @@ export class BackupFailedNotification extends BaseNotification {
return JSON.stringify(payload);
}
+ protected loadHTMLTemplate(): string {
+ return loadBackupTemplate('BackupFailedNotification.ejs');
+ }
+
protected buildHTMLContent(data: BackupFailedNotificationPayload): string {
// Generate the Email Body
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
@@ -102,7 +106,7 @@ export class BackupFailedNotification extends BaseNotification {
? providers[data.storageType]?.name || data.storageType
: '';
- const templateString = loadBackupTemplate('BackupFailedNotification.ejs');
+ const templateString = this.loadHTMLTemplate();
const renderedBody = ejs.render(templateString, {
...data,
appUrl: configService.config.APP_URL,
diff --git a/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts b/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts
index 3a7b9b6..05f1755 100644
--- a/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts
+++ b/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts
@@ -68,6 +68,10 @@ export class BackupStartedNotification extends BaseNotification {
return JSON.stringify(payload);
}
+ protected loadHTMLTemplate(): string {
+ return loadBackupTemplate('BackupStartedNotification.ejs');
+ }
+
protected buildHTMLContent(data: BackupStartedPayload): string {
// Generate the Email Body
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
@@ -82,7 +86,7 @@ export class BackupStartedNotification extends BaseNotification {
? providers[data.storageType]?.name || data.storageType
: '';
- const templateString = loadBackupTemplate('BackupStartedNotification.ejs');
+ const templateString = this.loadHTMLTemplate();
const renderedBody = ejs.render(templateString, {
...data,
appUrl: configService.config.APP_URL,
diff --git a/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts b/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts
index f610e21..1db08fc 100644
--- a/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts
+++ b/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts
@@ -86,6 +86,10 @@ export class BackupSuccessNotification extends BaseNotification {
return JSON.stringify(payload);
}
+ protected loadHTMLTemplate(): string {
+ return loadBackupTemplate('BackupSuccessNotification.ejs');
+ }
+
protected buildHTMLContent(data: BackupSuccessNotificationPayload): string {
// Generate the Email Body
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
@@ -105,7 +109,7 @@ export class BackupSuccessNotification extends BaseNotification {
const storageTypeName = data.storageType
? providers[data.storageType]?.name || data.storageType
: '';
- const templateString = loadBackupTemplate('BackupSuccessNotification.ejs');
+ const templateString = this.loadHTMLTemplate();
const renderedBody = ejs.render(templateString, {
...data,
appUrl: configService.config.APP_URL,
diff --git a/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts b/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts
index aaaa392..fbfdb11 100644
--- a/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts
+++ b/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts
@@ -70,6 +70,10 @@ export class ReplicationFailedNotification extends BaseNotification {
return JSON.stringify(payload);
}
+ protected loadHTMLTemplate(): string {
+ return loadBackupTemplate('ReplicationFailedNotification.ejs');
+ }
+
protected buildHTMLContent(data: ReplicationFailedNotificationPayload): string {
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
year: 'numeric',
@@ -89,7 +93,7 @@ export class ReplicationFailedNotification extends BaseNotification {
? providers[data.storageType]?.name || data.storageType
: '';
- const templateString = loadBackupTemplate('ReplicationFailedNotification.ejs');
+ const templateString = this.loadHTMLTemplate();
const renderedBody = ejs.render(templateString, {
...data,
appUrl: configService.config.APP_URL,