mirror of
https://github.com/plankanban/planka.git
synced 2025-12-17 01:11:23 +03:00
feat: Webhooks configuration, all events support, refactoring
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user