2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
record: {
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
request: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'ref',
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
async fn(inputs) {
|
2023-10-17 19:18:19 +02:00
|
|
|
await IdentityProviderUser.destroy({
|
|
|
|
userId: inputs.record.id,
|
|
|
|
});
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
await ProjectManager.destroy({
|
|
|
|
userId: inputs.record.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
await BoardMembership.destroy({
|
2019-11-05 18:01:42 +05:00
|
|
|
userId: inputs.record.id,
|
2019-08-31 04:07:25 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
await CardSubscription.destroy({
|
2019-11-05 18:01:42 +05:00
|
|
|
userId: inputs.record.id,
|
2019-08-31 04:07:25 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
await CardMembership.destroy({
|
2019-11-05 18:01:42 +05:00
|
|
|
userId: inputs.record.id,
|
2019-08-31 04:07:25 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
const user = await User.updateOne({
|
|
|
|
id: inputs.record.id,
|
2019-11-05 18:01:42 +05:00
|
|
|
deletedAt: null,
|
2019-08-31 04:07:25 +05:00
|
|
|
}).set({
|
2023-06-12 23:54:57 +02:00
|
|
|
deletedAt: new Date().toISOString(),
|
2019-08-31 04:07:25 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
if (user) {
|
2021-06-24 01:05:22 +05:00
|
|
|
/* const projectIds = await sails.helpers.users.getManagerProjectIds(user.id);
|
|
|
|
|
|
|
|
const userIds = _.union(
|
|
|
|
[user.id],
|
|
|
|
await sails.helpers.users.getAdminIds(),
|
|
|
|
await sails.helpers.projects.getManagerAndBoardMemberUserIds(projectIds),
|
|
|
|
); */
|
|
|
|
|
|
|
|
const users = await sails.helpers.users.getMany();
|
|
|
|
const userIds = [inputs.record.id, ...sails.helpers.utils.mapRecords(users)];
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-04-03 00:35:25 +05:00
|
|
|
userIds.forEach((userId) => {
|
2019-08-31 04:07:25 +05:00
|
|
|
sails.sockets.broadcast(
|
|
|
|
`user:${userId}`,
|
|
|
|
'userDelete',
|
|
|
|
{
|
2019-11-05 18:01:42 +05:00
|
|
|
item: user,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
inputs.request,
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
return user;
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|