Fix mail settings and add mail from

This commit is contained in:
Alice Gaudon 2020-06-27 18:06:39 +02:00
parent b043513fe8
commit ca39c3e538
4 changed files with 14 additions and 6 deletions

View File

@ -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

View File

@ -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 <alice@gaudon.pro>",

View File

@ -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<string>('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)}`;
}
}

View File

@ -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<void> {
private readonly application: Application;
@ -22,12 +23,12 @@ export default class MaintenanceComponent extends ApplicationComponent<void> {
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();