mirror of
https://github.com/plankanban/planka.git
synced 2025-12-18 01:11:13 +03:00
fix: Fix application crash after deleting project
This commit is contained in:
@@ -10,6 +10,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async fn(inputs) {
|
async fn(inputs) {
|
||||||
|
const boardIds = await sails.helpers.projects.getBoardIds(inputs.record.id);
|
||||||
|
|
||||||
|
await BoardMembership.destroy({
|
||||||
|
boardId: boardIds,
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
const projectManagers = await ProjectManager.destroy({
|
const projectManagers = await ProjectManager.destroy({
|
||||||
projectId: inputs.record.id,
|
projectId: inputs.record.id,
|
||||||
}).fetch();
|
}).fetch();
|
||||||
@@ -19,14 +25,14 @@ module.exports = {
|
|||||||
if (project) {
|
if (project) {
|
||||||
const managerUserIds = sails.helpers.utils.mapRecords(projectManagers, 'userId');
|
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 memberUserIds = await sails.helpers.boards.getMemberUserIds(boardIds);
|
||||||
const userIds = _.union(managerUserIds, memberUserIds);
|
const userIds = _.union(managerUserIds, memberUserIds);
|
||||||
|
|
||||||
userIds.forEach((userId) => {
|
userIds.forEach((userId) => {
|
||||||
sails.sockets.removeRoomMembersFromRooms(`user:${userId}`, boardRooms);
|
sails.sockets.removeRoomMembersFromRooms(
|
||||||
|
`user:${userId}`,
|
||||||
|
boardIds.map((boardId) => `board:${boardId}`),
|
||||||
|
);
|
||||||
|
|
||||||
sails.sockets.broadcast(
|
sails.sockets.broadcast(
|
||||||
`user:${userId}`,
|
`user:${userId}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user