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
47
server/api/helpers/actions/create-one.js
Normal file
47
server/api/helpers/actions/create-one.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const action = await Action.create({
|
||||
...inputs.values,
|
||||
cardId: inputs.card.id,
|
||||
userId: inputs.user.id,
|
||||
}).fetch();
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`board:${inputs.card.boardId}`,
|
||||
'actionCreate',
|
||||
{
|
||||
item: action,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
const subscriptionUserIds = await sails.helpers.cards.getSubscriptionUserIds(
|
||||
action.cardId,
|
||||
action.userId,
|
||||
);
|
||||
|
||||
subscriptionUserIds.forEach(async (userId) => {
|
||||
await sails.helpers.notifications.createOne(userId, action);
|
||||
});
|
||||
|
||||
return action;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue