feat: Add ability to configure and test SMTP via UI
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user