1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-20 05:39:43 +02:00
planka/server/api/helpers/attachments/update-one.js

47 lines
881 B
JavaScript
Raw Normal View History

2020-04-21 05:04:34 +05:00
module.exports = {
inputs: {
record: {
type: 'ref',
required: true,
},
values: {
type: 'json',
required: true,
},
board: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
2022-12-26 21:10:50 +01:00
const { values } = inputs;
const attachment = await Attachment.updateOne(inputs.record.id).set({ ...values });
2020-04-21 05:04:34 +05:00
if (attachment) {
sails.sockets.broadcast(
`board:${inputs.board.id}`,
'attachmentUpdate',
{
item: attachment,
},
inputs.request,
);
await sails.helpers.utils.sendWebhook.with({
event: 'ATTACHMENT_UPDATE',
data: attachment,
projectId: inputs.board.projectId,
user: inputs.request.currentUser,
board: inputs.board,
});
2020-04-21 05:04:34 +05:00
}
return attachment;
2020-04-21 05:04:34 +05:00
},
};