mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #9223, don't overwrite stmp settings
This commit is contained in:
@@ -47,8 +47,8 @@ const smtpSettingsChanged = (config) => {
|
|||||||
'email:smtpTransport:host',
|
'email:smtpTransport:host',
|
||||||
'email:smtpTransport:security',
|
'email:smtpTransport:security',
|
||||||
];
|
];
|
||||||
|
// config only has these properties if settings are saved on /admin/settings/email
|
||||||
return settings.some(key => config[key] !== prevConfig[key]);
|
return settings.some(key => config.hasOwnProperty(key) && config[key] !== prevConfig[key]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHostname = () => {
|
const getHostname = () => {
|
||||||
@@ -59,17 +59,21 @@ const getHostname = () => {
|
|||||||
|
|
||||||
const buildCustomTemplates = async (config) => {
|
const buildCustomTemplates = async (config) => {
|
||||||
try {
|
try {
|
||||||
const [templates, allPaths] = await Promise.all([
|
|
||||||
Emailer.getTemplates(config),
|
|
||||||
file.walk(viewsDir),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// If the new config contains any email override values, re-compile those templates
|
// If the new config contains any email override values, re-compile those templates
|
||||||
const toBuild = Object
|
const toBuild = Object
|
||||||
.keys(config)
|
.keys(config)
|
||||||
.filter(prop => prop.startsWith('email:custom:'))
|
.filter(prop => prop.startsWith('email:custom:'))
|
||||||
.map(key => key.split(':')[2]);
|
.map(key => key.split(':')[2]);
|
||||||
|
|
||||||
|
if (!toBuild.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [templates, allPaths] = await Promise.all([
|
||||||
|
Emailer.getTemplates(config),
|
||||||
|
file.walk(viewsDir),
|
||||||
|
]);
|
||||||
|
|
||||||
const templatesToBuild = templates.filter(template => toBuild.includes(template.path));
|
const templatesToBuild = templates.filter(template => toBuild.includes(template.path));
|
||||||
const paths = _.fromPairs(allPaths.map((p) => {
|
const paths = _.fromPairs(allPaths.map((p) => {
|
||||||
const relative = path.relative(viewsDir, p).replace(/\\/g, '/');
|
const relative = path.relative(viewsDir, p).replace(/\\/g, '/');
|
||||||
@@ -179,16 +183,18 @@ Emailer.registerApp = (expressApp) => {
|
|||||||
// which is updated before the pubsub handler is called
|
// which is updated before the pubsub handler is called
|
||||||
prevConfig = { ...meta.config };
|
prevConfig = { ...meta.config };
|
||||||
|
|
||||||
// Update default payload if new logo is uploaded
|
|
||||||
pubsub.on('config:update', (config) => {
|
pubsub.on('config:update', (config) => {
|
||||||
|
// config object only contains properties for the specific acp settings page
|
||||||
|
// not the entire meta.config object
|
||||||
if (config) {
|
if (config) {
|
||||||
if (config['brand:emailLogo']) {
|
// Update default payload if new logo is uploaded
|
||||||
|
if (config.hasOwnProperty('brand:emailLogo')) {
|
||||||
Emailer._defaultPayload.logo.src = config['brand:emailLogo'];
|
Emailer._defaultPayload.logo.src = config['brand:emailLogo'];
|
||||||
}
|
}
|
||||||
if (config['brand:emailLogo:height']) {
|
if (config.hasOwnProperty('brand:emailLogo:height')) {
|
||||||
Emailer._defaultPayload.logo.height = config['brand:emailLogo:height'];
|
Emailer._defaultPayload.logo.height = config['brand:emailLogo:height'];
|
||||||
}
|
}
|
||||||
if (config['brand:emailLogo:width']) {
|
if (config.hasOwnProperty('brand:emailLogo:width')) {
|
||||||
Emailer._defaultPayload.logo.width = config['brand:emailLogo:width'];
|
Emailer._defaultPayload.logo.width = config['brand:emailLogo:width'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +203,7 @@ Emailer.registerApp = (expressApp) => {
|
|||||||
}
|
}
|
||||||
buildCustomTemplates(config);
|
buildCustomTemplates(config);
|
||||||
|
|
||||||
prevConfig = config;
|
prevConfig = { ...prevConfig, ...config };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user