mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 06:39:44 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
45
server/api/helpers/project-managers/create-one.js
Normal file
45
server/api/helpers/project-managers/create-one.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
module.exports = {
|
||||
inputs: {
|
||||
user: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
userAlreadyProjectManager: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const projectManager = await ProjectManager.create({
|
||||
projectId: inputs.project.id,
|
||||
userId: inputs.user.id,
|
||||
})
|
||||
.intercept('E_UNIQUE', 'userAlreadyProjectManager')
|
||||
.fetch();
|
||||
|
||||
const userIds = await sails.helpers.projects.getManagerAndBoardMemberUserIds(
|
||||
projectManager.projectId,
|
||||
);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'projectManagerCreate',
|
||||
{
|
||||
item: projectManager,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
return projectManager;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue