2025-05-10 02:09:06 +02:00
|
|
|
/*!
|
|
|
|
* Copyright (c) 2024 PLANKA Software GmbH
|
|
|
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
|
|
|
*/
|
|
|
|
|
2020-04-21 05:04:34 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
record: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
values: {
|
|
|
|
type: 'json',
|
|
|
|
required: true,
|
|
|
|
},
|
2024-06-12 00:51:36 +02:00
|
|
|
project: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
2020-04-21 05:04:34 +05:00
|
|
|
board: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
2024-06-12 00:51:36 +02:00
|
|
|
list: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
card: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
actorUser: {
|
|
|
|
type: 'ref',
|
|
|
|
required: true,
|
|
|
|
},
|
2020-04-21 05:04:34 +05:00
|
|
|
request: {
|
|
|
|
type: 'ref',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
async fn(inputs) {
|
2022-12-26 21:10:50 +01:00
|
|
|
const { values } = inputs;
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const attachment = await Attachment.qm.updateOne(inputs.record.id, values);
|
2020-04-21 05:04:34 +05:00
|
|
|
|
|
|
|
if (attachment) {
|
|
|
|
sails.sockets.broadcast(
|
|
|
|
`board:${inputs.board.id}`,
|
|
|
|
'attachmentUpdate',
|
|
|
|
{
|
2025-05-10 02:09:06 +02:00
|
|
|
item: sails.helpers.attachments.presentOne(attachment),
|
2020-04-21 05:04:34 +05:00
|
|
|
},
|
|
|
|
inputs.request,
|
|
|
|
);
|
2024-06-06 20:22:14 +02:00
|
|
|
|
2024-06-12 00:51:36 +02:00
|
|
|
sails.helpers.utils.sendWebhooks.with({
|
|
|
|
event: 'attachmentUpdate',
|
2025-05-10 02:09:06 +02:00
|
|
|
buildData: () => ({
|
|
|
|
item: sails.helpers.attachments.presentOne(attachment),
|
2024-06-12 00:51:36 +02:00
|
|
|
included: {
|
|
|
|
projects: [inputs.project],
|
|
|
|
boards: [inputs.board],
|
|
|
|
lists: [inputs.list],
|
|
|
|
cards: [inputs.card],
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
}),
|
|
|
|
buildPrevData: () => ({
|
|
|
|
item: sails.helpers.attachments.presentOne(inputs.record),
|
|
|
|
}),
|
2024-06-12 00:51:36 +02:00
|
|
|
user: inputs.actorUser,
|
2024-06-06 20:22:14 +02:00
|
|
|
});
|
2020-04-21 05:04:34 +05:00
|
|
|
}
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
return attachment;
|
2020-04-21 05:04:34 +05:00
|
|
|
},
|
|
|
|
};
|