1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

fix: Change way to fix application crash when deleting project

This commit is contained in:
Maksim Eltyshev 2022-04-28 14:15:36 +05:00
parent ad04208c8a
commit e7541789cd
2 changed files with 23 additions and 18 deletions

View file

@ -10,12 +10,6 @@ module.exports = {
},
async fn(inputs) {
const boardIds = await sails.helpers.projects.getBoardIds(inputs.record.id);
await BoardMembership.destroy({
boardId: boardIds,
}).fetch();
const projectManagers = await ProjectManager.destroy({
projectId: inputs.record.id,
}).fetch();
@ -25,14 +19,14 @@ module.exports = {
if (project) {
const managerUserIds = sails.helpers.utils.mapRecords(projectManagers, 'userId');
const boardIds = await sails.helpers.projects.getBoardIds(project.id);
const boardRooms = boardIds.map((boardId) => `board:${boardId}`);
const memberUserIds = await sails.helpers.boards.getMemberUserIds(boardIds);
const userIds = _.union(managerUserIds, memberUserIds);
userIds.forEach((userId) => {
sails.sockets.removeRoomMembersFromRooms(
`user:${userId}`,
boardIds.map((boardId) => `board:${boardId}`),
);
sails.sockets.removeRoomMembersFromRooms(`user:${userId}`, boardRooms);
sails.sockets.broadcast(
`user:${userId}`,