chore: Allow only automatisch emails for non-prod cloud envs

This commit is contained in:
Faruk AYDIN
2023-06-08 11:58:14 +02:00
parent 35863ee6e9
commit 337d22bbf4

View File

@@ -7,11 +7,27 @@ import mailer from '../helpers/mailer.ee';
import compileEmail from '../helpers/compile-email.ee';
import appConfig from '../config/app';
const isCloudSandbox = () => {
return appConfig.isCloud && !appConfig.isProd;
};
const isAutomatischEmail = (email: string) => {
return email.endsWith('@automatisch.io');
};
export const worker = new Worker(
'email',
async (job) => {
const { email, subject, template, params } = job.data;
if (isCloudSandbox && !isAutomatischEmail(email)) {
logger.info(
'Only Automatisch emails are allowed for non-production environments!'
);
return;
}
await mailer.sendMail({
to: email,
from: appConfig.fromEmail,