mirror of
https://github.com/plankanban/planka.git
synced 2025-08-04 21:15:25 +02:00
parent
ad7fb51cfa
commit
2ee1166747
1557 changed files with 76832 additions and 47042 deletions
|
@ -0,0 +1,79 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
limitReached: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const notificationServicesTotal = await sails.helpers.boards.getNotificationServicesTotal(
|
||||
values.board.id,
|
||||
);
|
||||
|
||||
// TODO: move to config?
|
||||
if (notificationServicesTotal >= 5) {
|
||||
throw 'limitReached';
|
||||
}
|
||||
|
||||
const notificationService = await NotificationService.qm.createOne({
|
||||
...values,
|
||||
boardId: values.board.id,
|
||||
});
|
||||
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
notificationService,
|
||||
record: inputs.project,
|
||||
board: values.board,
|
||||
});
|
||||
|
||||
const notificationServiceRelatedUserIds = await scoper.getNotificationServiceRelatedUserIds();
|
||||
|
||||
notificationServiceRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'notificationServiceCreate',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceCreate',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [values.board],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,64 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
limitReached: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const notificationServicesTotal = await sails.helpers.users.getNotificationServicesTotal(
|
||||
values.user.id,
|
||||
);
|
||||
|
||||
// TODO: move to config?
|
||||
if (notificationServicesTotal >= 5) {
|
||||
throw 'limitReached';
|
||||
}
|
||||
|
||||
const notificationService = await NotificationService.qm.createOne({
|
||||
...values,
|
||||
userId: values.user.id,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`user:${notificationService.userId}`,
|
||||
'notificationServiceCreate',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceCreate',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
users: [values.user],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,67 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const notificationService = await NotificationService.qm.deleteOne(inputs.record.id);
|
||||
|
||||
if (notificationService) {
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
notificationService,
|
||||
record: inputs.project,
|
||||
board: inputs.board,
|
||||
});
|
||||
|
||||
const notificationServiceRelatedUserIds = await scoper.getNotificationServiceRelatedUserIds();
|
||||
|
||||
notificationServiceRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'notificationServiceDelete',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceDelete',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,52 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const notificationService = await NotificationService.qm.deleteOne(inputs.record.id);
|
||||
|
||||
if (notificationService) {
|
||||
sails.sockets.broadcast(
|
||||
`user:${notificationService.userId}`,
|
||||
'notificationServiceDelete',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceDelete',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
users: [inputs.user],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,56 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const notificationService = await NotificationService.qm.getOneById(inputs.id);
|
||||
|
||||
if (!notificationService) {
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
let pathToProject;
|
||||
if (notificationService.userId) {
|
||||
const user = await User.qm.getOneById(notificationService.userId);
|
||||
|
||||
if (!user) {
|
||||
throw {
|
||||
pathNotFound: {
|
||||
notificationService,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pathToProject = {
|
||||
user,
|
||||
};
|
||||
} else if (notificationService.boardId) {
|
||||
pathToProject = await sails.helpers.boards
|
||||
.getPathToProjectById(notificationService.boardId)
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
notificationService,
|
||||
...nodes,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
return {
|
||||
notificationService,
|
||||
...pathToProject,
|
||||
};
|
||||
},
|
||||
};
|
33
server/api/helpers/notification-services/test-one.js
Normal file
33
server/api/helpers/notification-services/test-one.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
i18n: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { i18n } = inputs;
|
||||
|
||||
await sails.helpers.utils.sendNotifications.with({
|
||||
services: [_.pick(inputs.record, ['url', 'format'])],
|
||||
title: i18n.__('Test Title'),
|
||||
bodyByFormat: {
|
||||
text: i18n.__('This is a test text message!'),
|
||||
markdown: i18n.__('This is a *test* **markdown** `message`!'),
|
||||
html: i18n.__('This is a <i>test</i> <b>html</b> <code>message</code>'),
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
|
@ -0,0 +1,76 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const notificationService = await NotificationService.qm.updateOne(inputs.record.id, values);
|
||||
|
||||
if (notificationService) {
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
notificationService,
|
||||
record: inputs.project,
|
||||
board: inputs.board,
|
||||
});
|
||||
|
||||
const notificationServiceRelatedUserIds = await scoper.getNotificationServiceRelatedUserIds();
|
||||
|
||||
notificationServiceRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'notificationServiceUpdate',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceUpdate',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
}),
|
||||
buildPrevData: () => ({
|
||||
item: inputs.record,
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,61 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const notificationService = await NotificationService.qm.updateOne(inputs.record.id, values);
|
||||
|
||||
if (notificationService) {
|
||||
sails.sockets.broadcast(
|
||||
`user:${notificationService.userId}`,
|
||||
'notificationServiceUpdate',
|
||||
{
|
||||
item: notificationService,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationServiceUpdate',
|
||||
buildData: () => ({
|
||||
item: notificationService,
|
||||
included: {
|
||||
users: [inputs.user],
|
||||
},
|
||||
}),
|
||||
buildPrevData: () => ({
|
||||
item: inputs.record,
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return notificationService;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue