1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-20 13:49:43 +02:00

Project managers, board members, auto-update after reconnection, refactoring

This commit is contained in:
Maksim Eltyshev 2021-06-24 01:05:22 +05:00
parent d6cb1f6683
commit b39119ace4
478 changed files with 21226 additions and 19495 deletions

View file

@ -19,42 +19,41 @@ module.exports = {
},
},
async fn(inputs, exits) {
async fn(inputs) {
const { currentUser } = this.req;
const criteria = {
id: inputs.id,
type: 'commentCard',
};
if (!currentUser.isAdmin) {
criteria.userId = currentUser.id;
}
const actionToProjectPath = await sails.helpers
.getActionToProjectPath(criteria)
const path = await sails.helpers.actions
.getProjectPath({
id: inputs.id,
type: Action.Types.COMMENT_CARD,
})
.intercept('pathNotFound', () => Errors.COMMENT_ACTION_NOT_FOUND);
let { action } = actionToProjectPath;
const { board, project } = actionToProjectPath;
let { action } = path;
const { board, project } = path;
const isUserMemberForProject = await sails.helpers.isUserMemberForProject(
project.id,
currentUser.id,
);
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
if (!isUserMemberForProject) {
throw Errors.COMMENT_ACTION_NOT_FOUND; // Forbidden
if (!isProjectManager) {
if (action.userId !== currentUser.id) {
throw Errors.COMMENT_ACTION_NOT_FOUND; // Forbidden
}
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, board.id);
if (!isBoardMember) {
throw Errors.COMMENT_ACTION_NOT_FOUND; // Forbidden
}
}
action = await sails.helpers.deleteAction(action, board, this.req);
action = await sails.helpers.actions.deleteOne(action, board, this.req);
if (!action) {
throw Errors.COMMENT_ACTION_NOT_FOUND;
}
return exits.success({
return {
item: action,
});
};
},
};