1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-21 22:29:42 +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

@ -13,7 +13,7 @@ module.exports = {
},
type: {
type: 'string',
isIn: Board.TYPES,
isIn: Object.values(Board.Types),
required: true,
},
position: {
@ -32,29 +32,42 @@ module.exports = {
},
},
async fn(inputs, exits) {
async fn(inputs) {
// TODO: allow over HTTP without subscription
if (!this.req.isSocket) {
return this.res.badRequest();
}
const { currentUser } = this.req;
const project = await Project.findOne(inputs.projectId);
if (!project) {
throw Errors.PROJECT_NOT_FOUND;
}
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
if (!isProjectManager) {
throw Errors.PROJECT_NOT_FOUND; // Forbidden
}
const values = _.pick(inputs, ['type', 'position', 'name']);
const board = await sails.helpers.createBoard(project, values, this.req);
const { board, boardMembership } = await sails.helpers.boards.createOne(
values,
currentUser,
project,
this.req,
);
sails.sockets.join(this.req, `board:${board.id}`); // TODO: only when subscription needed
return exits.success({
return {
item: board,
included: {
lists: [],
labels: [],
boardMemberships: [boardMembership],
},
});
};
},
};