1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

feat: Webhooks configuration, all events support, refactoring

This commit is contained in:
Maksim Eltyshev 2024-06-12 00:51:36 +02:00
parent 193daf6cfb
commit 87683fe523
96 changed files with 1280 additions and 509 deletions

View file

@ -38,7 +38,7 @@ module.exports = {
custom: valuesValidator,
required: true,
},
user: {
actorUser: {
type: 'ref',
required: true,
},
@ -62,14 +62,14 @@ module.exports = {
let isOnlyPasswordChange = false;
if (!_.isUndefined(values.password)) {
if (Object.keys(values).length === 1) {
isOnlyPasswordChange = true;
}
Object.assign(values, {
password: bcrypt.hashSync(values.password, 10),
passwordChangedAt: new Date().toISOString(),
});
if (Object.keys(values).length === 1) {
isOnlyPasswordChange = true;
}
}
if (values.username) {
@ -118,7 +118,7 @@ module.exports = {
inputs.request,
);
if (user.id === inputs.user.id && inputs.request && inputs.request.isSocket) {
if (user.id === inputs.actorUser.id && inputs.request && inputs.request.isSocket) {
const tempRoom = uuid();
sails.sockets.addRoomMembersToRooms(`@user:${user.id}`, tempRoom, () => {
@ -153,14 +153,15 @@ module.exports = {
inputs.request,
);
});
}
await sails.helpers.utils.sendWebhook.with({
event: 'USER_UPDATE',
data: { ...user, password: undefined },
projectId: '',
user: inputs.request.currentUser,
});
sails.helpers.utils.sendWebhooks.with({
event: 'userUpdate',
data: {
item: user,
},
user: inputs.actorUser,
});
}
}
return user;