feat: Add ability to configure and test SMTP via UI

This commit is contained in:
Maksim Eltyshev
2025-09-22 20:35:13 +02:00
parent 3a12bb7457
commit c6f4dcdb70
114 changed files with 2161 additions and 301 deletions
+7 -10
View File
@@ -11,20 +11,17 @@ module.exports = {
type: 'ref',
required: true,
},
user: {
type: 'ref',
},
},
fn(inputs) {
const data = {
...inputs.record,
version: sails.config.custom.version,
};
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
data.activeUsersLimit = sails.config.custom.activeUsersLimit;
if (sails.config.custom.smtpHost) {
return _.omit(inputs.record, Config.SMTP_FIELD_NAMES);
}
return data;
if (inputs.record.smtpPassword) {
return _.omit(inputs.record, 'smtpPassword');
}
return inputs.record;
},
};
+53
View File
@@ -0,0 +1,53 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
module.exports = {
inputs: {
values: {
type: 'json',
required: true,
},
actorUser: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const { values } = inputs;
const config = await Config.qm.updateOneMain(values);
const configRelatedUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
configRelatedUserIds.forEach((userId) => {
sails.sockets.broadcast(
`user:${userId}`,
'configUpdate',
{
item: sails.helpers.config.presentOne(config),
},
inputs.request,
);
});
const webhooks = await Webhook.qm.getAll();
// TODO: with prevData?
sails.helpers.utils.sendWebhooks.with({
webhooks,
event: Webhook.Events.CONFIG_UPDATE,
buildData: () => ({
item: sails.helpers.config.presentOne(config),
}),
user: inputs.actorUser,
});
return config;
},
};