feat: Add internal runtime configuration

This commit is contained in:
Maksim Eltyshev
2026-01-22 18:02:42 +01:00
parent b852481850
commit 1264fd5715
79 changed files with 561 additions and 122 deletions
@@ -42,12 +42,12 @@ module.exports = {
},
async fn(inputs) {
const config = await Config.qm.getOneMain();
const internalConfig = await InternalConfig.qm.getOneMain();
if (!config.isInitialized) {
if (!internalConfig.isInitialized) {
if (inputs.user.role === User.Roles.ADMIN) {
if (inputs.user.termsSignature) {
await Config.qm.updateOneMain({
await InternalConfig.qm.updateOneMain({
isInitialized: true,
});
}
+5 -1
View File
@@ -7,6 +7,10 @@ module.exports = {
sync: true,
inputs: {
internalConfig: {
type: 'ref',
required: true,
},
oidc: {
type: 'ref',
},
@@ -22,7 +26,7 @@ module.exports = {
};
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
Object.assign(data, {
activeUserLimit: sails.config.custom.activeUserLimit,
activeUsersLimit: inputs.internalConfig.activeUsersLimit,
customerPanelUrl: sails.config.custom.customerPanelUrl,
});
}
@@ -0,0 +1,54 @@
/*!
* 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,
},
},
async fn(inputs) {
const { values } = inputs;
const { internalConfig, deactivatedUserIds, prev } =
await InternalConfig.qm.updateOneMain(values);
if (deactivatedUserIds) {
deactivatedUserIds.forEach((userId) => {
sails.sockets.broadcast(`user:${userId}`, 'logout');
sails.sockets.leaveAll(`@user:${userId}`);
});
}
if (internalConfig.activeUsersLimit !== prev.activeUsersLimit) {
let adminUserIds;
if (deactivatedUserIds && deactivatedUserIds.length > 0) {
const users = await User.qm.getAll({
roleOrRoles: [User.Roles.ADMIN, User.Roles.PROJECT_OWNER],
});
adminUserIds = users.flatMap((user) => {
sails.sockets.broadcast(`user:${user.id}`, 'usersReset');
return user.role === User.Roles.ADMIN ? user.id : [];
});
} else {
adminUserIds = await sails.helpers.users.getAllIds(User.Roles.ADMIN);
}
adminUserIds.forEach((userId) => {
sails.sockets.broadcast(`user:${userId}`, 'bootstrapUpdate', {
item: {
activeUsersLimit: internalConfig.activeUsersLimit,
},
});
});
}
return internalConfig;
},
};
+1 -8
View File
@@ -112,14 +112,7 @@ module.exports = {
}
if (!_.isUndefined(values.password) || isDeactivatedChangeToTrue) {
sails.sockets.broadcast(
`user:${user.id}`,
'userDelete', // TODO: introduce separate event
{
item: sails.helpers.users.presentOne(user, user),
},
inputs.request,
);
sails.sockets.broadcast(`user:${user.id}`, 'logout', undefined, inputs.request);
if (
!isDeactivatedChangeToTrue &&
@@ -3,9 +3,12 @@
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const bytes = require('bytes');
module.exports = {
async fn() {
const { storageLimit } = sails.config.custom;
let { storageLimit } = await InternalConfig.qm.getOneMain();
storageLimit = bytes(storageLimit);
if (storageLimit === null) {
return null;