mirror of
https://github.com/plankanban/planka.git
synced 2025-07-20 13:49:43 +02:00
feat: Webhooks configuration, all events support, refactoring
This commit is contained in:
parent
3779bdb053
commit
c065566c15
96 changed files with 1280 additions and 509 deletions
|
@ -21,10 +21,18 @@ module.exports = {
|
|||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
requestId: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
|
@ -35,7 +43,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values, board } = inputs;
|
||||
const { values } = inputs;
|
||||
|
||||
const attachment = await Attachment.create({
|
||||
...values,
|
||||
|
@ -53,26 +61,33 @@ module.exports = {
|
|||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'attachmentCreate',
|
||||
data: {
|
||||
item: attachment,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
},
|
||||
user: values.creatorUser,
|
||||
});
|
||||
|
||||
if (!values.card.coverAttachmentId && attachment.image) {
|
||||
await sails.helpers.cards.updateOne.with({
|
||||
record: values.card,
|
||||
values: {
|
||||
coverAttachmentId: attachment.id,
|
||||
},
|
||||
board,
|
||||
request: inputs.request,
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: inputs.list,
|
||||
actorUser: values.creatorUser,
|
||||
});
|
||||
}
|
||||
|
||||
await sails.helpers.utils.sendWebhook.with({
|
||||
event: 'ATTACHMENT_CREATE',
|
||||
data: attachment,
|
||||
projectId: board.projectId,
|
||||
user: inputs.request.currentUser,
|
||||
card: values.card,
|
||||
board,
|
||||
});
|
||||
|
||||
return attachment;
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue