mirror of
https://github.com/plankanban/planka.git
synced 2025-07-21 22:29:42 +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
|
@ -12,8 +12,9 @@ module.exports = {
|
|||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
|
@ -23,7 +24,9 @@ module.exports = {
|
|||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const criteria = {};
|
||||
const criteria = {
|
||||
userId: inputs.actorUser.id,
|
||||
};
|
||||
|
||||
if (_.every(inputs.recordsOrIds, _.isPlainObject)) {
|
||||
criteria.id = sails.helpers.utils.mapRecords(inputs.recordsOrIds);
|
||||
|
@ -31,10 +34,6 @@ module.exports = {
|
|||
criteria.id = inputs.recordsOrIds;
|
||||
}
|
||||
|
||||
if (inputs.user) {
|
||||
criteria.userId = inputs.user.id;
|
||||
}
|
||||
|
||||
const notifications = await Notification.update(criteria)
|
||||
.set({ ...values })
|
||||
.fetch();
|
||||
|
@ -48,6 +47,14 @@ module.exports = {
|
|||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationUpdate',
|
||||
data: {
|
||||
item: notification,
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
});
|
||||
|
||||
return notifications;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue