2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
record: {
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
values: {
|
|
|
|
type: 'json',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
request: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'ref',
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
async fn(inputs, exits) {
|
|
|
|
const project = await Project.updateOne(inputs.record.id).set(inputs.values);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
if (project) {
|
2019-11-05 18:01:42 +05:00
|
|
|
const userIds = await sails.helpers.getMembershipUserIdsForProject(project.id);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
userIds.forEach(userId => {
|
2019-08-31 04:07:25 +05:00
|
|
|
sails.sockets.broadcast(
|
|
|
|
`user:${userId}`,
|
|
|
|
'projectUpdate',
|
|
|
|
{
|
2019-11-05 18:01:42 +05:00
|
|
|
item: project,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
inputs.request,
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return exits.success(project);
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|