2020-04-22 15:52:17 +02:00
|
|
|
import ApplicationComponent from "../ApplicationComponent";
|
2020-07-11 11:46:16 +02:00
|
|
|
import {Express} from "express";
|
2020-04-22 15:52:17 +02:00
|
|
|
import Mail from "../Mail";
|
2020-07-15 15:06:13 +02:00
|
|
|
import config from "config";
|
|
|
|
import SecurityError from "../SecurityError";
|
2020-04-22 15:52:17 +02:00
|
|
|
|
|
|
|
export default class MailComponent extends ApplicationComponent<void> {
|
2020-07-15 15:06:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
public async checkSecuritySettings(): Promise<void> {
|
|
|
|
if (!config.get<boolean>('mail.secure')) {
|
|
|
|
throw new SecurityError('Cannot set mail.secure to false');
|
|
|
|
}
|
|
|
|
if (config.get<boolean>('mail.allow_invalid_tls')) {
|
|
|
|
throw new SecurityError('Cannot set mail.allow_invalid_tls to true');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-11 11:46:16 +02:00
|
|
|
public async start(app: Express): Promise<void> {
|
2020-04-22 15:52:17 +02:00
|
|
|
await this.prepare('Mail connection', () => Mail.prepare());
|
|
|
|
}
|
|
|
|
|
|
|
|
public async stop(): Promise<void> {
|
|
|
|
Mail.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|