From ca39c3e538762f14bb38ad5bdf0df6beb23d98b2 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 27 Jun 2020 18:06:39 +0200 Subject: [PATCH] Fix mail settings and add mail from --- config/default.ts | 6 ++++-- package.json | 2 +- src/Mail.ts | 7 ++++++- src/components/MaintenanceComponent.ts | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config/default.ts b/config/default.ts index 95072f6..a41482a 100644 --- a/config/default.ts +++ b/config/default.ts @@ -1,7 +1,7 @@ export default { app: { name: 'Example App', - contact_email: 'noreply@example.net' + contact_email: 'contact@example.net' }, log_level: "DEV", db_log_level: "ERROR", @@ -34,7 +34,9 @@ export default { secure: false, username: "", password: "", - allow_invalid_tls: true + allow_invalid_tls: true, + from: 'contact@example.net', + from_name: 'Example App', }, view: { cache: false diff --git a/package.json b/package.json index 13357ef..2f32273 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-core", - "version": "0.10.16", + "version": "0.10.18", "description": "Node web framework", "repository": "git@gitlab.com:ArisuOngaku/wms-core.git", "author": "Alice Gaudon ", diff --git a/src/Mail.ts b/src/Mail.ts index 3355c44..267be88 100644 --- a/src/Mail.ts +++ b/src/Mail.ts @@ -93,11 +93,16 @@ export default class Mail { // Set options this.options.to = destEmail; + this.options.from = { + name: config.get('mail.from_name'), + address: config.get('mail.from'), + }; // Set data this.data.mail_subject = this.options.subject; this.data.mail_to = this.options.to; this.data.mail_link = `${config.get('public_url')}${mailRoute(this.template.template)}?${querystring.stringify(this.data)}`; + this.data.app = config.get('app'); // Log Logger.dev('Send mail', this.options); @@ -128,7 +133,7 @@ export class MailTemplate { } public getSubject(data: any): string { - return 'Watch My Stream - ' + this.subject(data); + return `${config.get('app.name')} - ${this.subject(data)}`; } } diff --git a/src/components/MaintenanceComponent.ts b/src/components/MaintenanceComponent.ts index 76a18d7..fc766f4 100644 --- a/src/components/MaintenanceComponent.ts +++ b/src/components/MaintenanceComponent.ts @@ -2,6 +2,7 @@ import ApplicationComponent from "../ApplicationComponent"; import {Express, NextFunction, Request, Response, Router} from "express"; import {ServiceUnavailableHttpError} from "../HttpError"; import Application from "../Application"; +import config from "config"; export default class MaintenanceComponent extends ApplicationComponent { private readonly application: Application; @@ -22,12 +23,12 @@ export default class MaintenanceComponent extends ApplicationComponent { if (!this.application.isReady()) { res.header({'Retry-After': 60}); res.locals.refresh_after = 5; - throw new ServiceUnavailableHttpError('Watch My Stream is readying up. Please wait a few seconds...'); + throw new ServiceUnavailableHttpError(`${config.get('app.name')} is readying up. Please wait a few seconds...`); } if (!this.canServe()) { res.locals.refresh_after = 30; - throw new ServiceUnavailableHttpError('Watch My Stream is unavailable due to failure of dependent services.'); + throw new ServiceUnavailableHttpError(`${config.get('app.name')} is unavailable due to failure of dependent services.`); } next();