import Planka upstream
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
import: {
|
||||
type: 'json',
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
requestId: {
|
||||
type: 'string',
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
record: values.project,
|
||||
});
|
||||
|
||||
const boards = await Board.qm.getByProjectId(values.project.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
boards,
|
||||
);
|
||||
|
||||
values.position = position;
|
||||
|
||||
if (repositions.length > 0) {
|
||||
await scoper.getUserIdsWithFullProjectVisibility();
|
||||
const clonedScoper = scoper.clone();
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await Board.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
projectId: reposition.record.projectId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
clonedScoper.replaceBoard(reposition.record);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const boardRelatedUserIds = await clonedScoper.getBoardRelatedUserIds();
|
||||
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
|
||||
const { board, boardMembership, lists } = await Board.qm.createOne(
|
||||
{
|
||||
...values,
|
||||
projectId: values.project.id,
|
||||
},
|
||||
{
|
||||
user: inputs.actorUser,
|
||||
},
|
||||
);
|
||||
|
||||
if (inputs.import && inputs.import.type === Board.ImportTypes.TRELLO) {
|
||||
await sails.helpers.boards.importFromTrello(board, lists, inputs.import.board);
|
||||
}
|
||||
|
||||
scoper.board = board;
|
||||
scoper.boardMemberships = [boardMembership];
|
||||
|
||||
const boardRelatedUserIds = await scoper.getBoardRelatedUserIds();
|
||||
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardCreate',
|
||||
{
|
||||
item: board,
|
||||
included: {
|
||||
boardMemberships: userId === boardMembership.userId ? [boardMembership] : [],
|
||||
},
|
||||
requestId: inputs.requestId,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
const webhooks = await Webhook.qm.getAll();
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
webhooks,
|
||||
event: Webhook.Events.BOARD_CREATE,
|
||||
buildData: () => ({
|
||||
item: board,
|
||||
included: {
|
||||
projects: [values.project],
|
||||
boardMemberships: [boardMembership],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return {
|
||||
board,
|
||||
boardMembership,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { boardMemberships } = await sails.helpers.boards.deleteRelated(inputs.record);
|
||||
|
||||
const board = await Board.qm.deleteOne(inputs.record.id);
|
||||
|
||||
if (board) {
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
board,
|
||||
record: inputs.project,
|
||||
});
|
||||
|
||||
scoper.boardMemberships = boardMemberships;
|
||||
const boardRelatedUserIds = await scoper.getBoardRelatedUserIds();
|
||||
|
||||
sails.sockets.removeRoomMembersFromRooms(`board:${board.id}`, `board:${board.id}`);
|
||||
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardDelete',
|
||||
{
|
||||
item: board,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
const webhooks = await Webhook.qm.getAll();
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
webhooks,
|
||||
event: Webhook.Events.BOARD_DELETE,
|
||||
buildData: () => ({
|
||||
item: board,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return board;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
recordOrRecords: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
let boardIdOrIds;
|
||||
if (_.isPlainObject(inputs.recordOrRecords)) {
|
||||
({
|
||||
recordOrRecords: { id: boardIdOrIds },
|
||||
} = inputs);
|
||||
} else if (_.every(inputs.recordOrRecords, _.isPlainObject)) {
|
||||
boardIdOrIds = sails.helpers.utils.mapRecords(inputs.recordOrRecords);
|
||||
}
|
||||
|
||||
const boardMemberships = await BoardMembership.qm.delete({
|
||||
boardId: boardIdOrIds,
|
||||
});
|
||||
|
||||
await Label.qm.delete({
|
||||
boardId: boardIdOrIds,
|
||||
});
|
||||
|
||||
const lists = await List.qm.delete({
|
||||
boardId: boardIdOrIds,
|
||||
});
|
||||
|
||||
await sails.helpers.lists.deleteRelated(lists);
|
||||
|
||||
await Action.qm.update(
|
||||
{
|
||||
boardId: boardIdOrIds,
|
||||
},
|
||||
{
|
||||
boardId: null,
|
||||
},
|
||||
);
|
||||
|
||||
await NotificationService.qm.delete({
|
||||
boardId: boardIdOrIds,
|
||||
});
|
||||
|
||||
return { boardMemberships };
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const cards = await Card.qm.getByBoardId(inputs.id);
|
||||
|
||||
return sails.helpers.utils.mapRecords(cards);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
exceptListIdOrIds: {
|
||||
type: 'json',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
return List.qm.getByBoardId(inputs.id, {
|
||||
exceptIdOrIds: inputs.exceptListIdOrIds,
|
||||
typeOrTypes: List.KANBAN_TYPES,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const boardMemberships = await BoardMembership.qm.getByBoardId(inputs.id);
|
||||
|
||||
return sails.helpers.utils.mapRecords(boardMemberships, 'userId');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const notificationServices = await NotificationService.qm.getByBoardId(inputs.id);
|
||||
|
||||
return notificationServices.length;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
/*!
|
||||
* 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 board = await Board.qm.getOneById(inputs.id);
|
||||
|
||||
if (!board) {
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
const project = await Project.qm.getOneById(board.projectId);
|
||||
|
||||
if (!project) {
|
||||
throw {
|
||||
pathNotFound: {
|
||||
board,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
board,
|
||||
project,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
exceptUserIdOrIds: {
|
||||
type: 'json',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const boardSubscriptions = await BoardSubscription.qm.getByBoardId(inputs.id, {
|
||||
exceptUserIdOrIds: inputs.exceptUserIdOrIds,
|
||||
});
|
||||
|
||||
return sails.helpers.utils.mapRecords(boardSubscriptions, 'userId');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,133 @@
|
||||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const { POSITION_GAP } = require('../../../constants');
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
lists: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
trelloBoard: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const convertLabelColor = (trelloLabelColor) =>
|
||||
Label.COLORS.find((color) => color.includes(trelloLabelColor)) || 'desert-sand';
|
||||
|
||||
const labelIdByTrelloLabelId = {};
|
||||
await Promise.all(
|
||||
inputs.trelloBoard.labels.map(async (trelloLabel, index) => {
|
||||
const { id } = await Label.qm.createOne({
|
||||
boardId: inputs.board.id,
|
||||
position: POSITION_GAP * (index + 1),
|
||||
name: trelloLabel.name || null,
|
||||
color: convertLabelColor(trelloLabel.color),
|
||||
});
|
||||
|
||||
labelIdByTrelloLabelId[trelloLabel.id] = id;
|
||||
}),
|
||||
);
|
||||
|
||||
const openedTrelloLists = inputs.trelloBoard.lists.filter((list) => !list.closed);
|
||||
|
||||
const listIdByTrelloListId = {};
|
||||
await Promise.all(
|
||||
openedTrelloLists.map(async (trelloList) => {
|
||||
const { id } = await List.qm.createOne({
|
||||
boardId: inputs.board.id,
|
||||
type: List.Types.ACTIVE,
|
||||
position: trelloList.pos,
|
||||
name: trelloList.name,
|
||||
});
|
||||
|
||||
listIdByTrelloListId[trelloList.id] = id;
|
||||
}),
|
||||
);
|
||||
|
||||
const { id: archiveListId } = inputs.lists.find((list) => list.type === List.Types.ARCHIVE);
|
||||
|
||||
const cardIdByTrelloCardId = {};
|
||||
await Promise.all(
|
||||
inputs.trelloBoard.cards.map(async (trelloCard) => {
|
||||
const values = {
|
||||
boardId: inputs.board.id,
|
||||
type: Card.Types.PROJECT,
|
||||
position: trelloCard.pos,
|
||||
name: trelloCard.name,
|
||||
description: trelloCard.desc || null,
|
||||
dueDate: trelloCard.due,
|
||||
isDueCompleted: trelloCard.due && trelloCard.dueComplete,
|
||||
listChangedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
const listId = listIdByTrelloListId[trelloCard.idList];
|
||||
|
||||
if (trelloCard.closed) {
|
||||
Object.assign(values, {
|
||||
listId: archiveListId,
|
||||
prevListId: listId,
|
||||
});
|
||||
} else {
|
||||
values.listId = listId || archiveListId;
|
||||
}
|
||||
|
||||
const { id } = await Card.qm.createOne(values);
|
||||
cardIdByTrelloCardId[trelloCard.id] = id;
|
||||
|
||||
return Promise.all(
|
||||
trelloCard.idLabels.map(async (trelloLabelId) =>
|
||||
CardLabel.qm.createOne({
|
||||
cardId: id,
|
||||
labelId: labelIdByTrelloLabelId[trelloLabelId],
|
||||
}),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
inputs.trelloBoard.checklists.map(async (trelloChecklist) => {
|
||||
const { id } = await TaskList.qm.createOne({
|
||||
cardId: cardIdByTrelloCardId[trelloChecklist.idCard],
|
||||
position: trelloChecklist.pos,
|
||||
name: trelloChecklist.name,
|
||||
});
|
||||
|
||||
return Promise.all(
|
||||
trelloChecklist.checkItems.map(async (trelloCheckItem) =>
|
||||
Task.qm.createOne({
|
||||
taskListId: id,
|
||||
position: trelloCheckItem.pos,
|
||||
name: trelloCheckItem.name,
|
||||
isCompleted: trelloCheckItem.state === 'complete',
|
||||
}),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
const trelloCommentActions = inputs.trelloBoard.actions
|
||||
.filter((action) => action.type === 'commentCard')
|
||||
.reverse();
|
||||
|
||||
await Promise.all(
|
||||
trelloCommentActions.map(async (trelloAction) =>
|
||||
Comment.qm.createOne({
|
||||
cardId: cardIdByTrelloCardId[trelloAction.data.card.id],
|
||||
text: `${trelloAction.data.text}\n\n---\n*Note: imported comment, originally posted by\n${trelloAction.memberCreator.fullName} (${trelloAction.memberCreator.username}) on ${trelloAction.date}*`,
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const { rimraf } = require('rimraf');
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
file: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
invalidFile: {},
|
||||
},
|
||||
|
||||
// TODO: add better validation
|
||||
async fn(inputs) {
|
||||
const content = await fs.promises.readFile(inputs.file.fd);
|
||||
|
||||
let trelloBoard;
|
||||
try {
|
||||
trelloBoard = JSON.parse(content);
|
||||
} catch (error) {
|
||||
await rimraf(inputs.file.fd);
|
||||
throw 'invalidFile';
|
||||
}
|
||||
|
||||
if (
|
||||
!trelloBoard ||
|
||||
!_.isArray(trelloBoard.labels) ||
|
||||
!_.isArray(trelloBoard.lists) ||
|
||||
!_.isArray(trelloBoard.cards) ||
|
||||
!_.isArray(trelloBoard.checklists) ||
|
||||
!_.isArray(trelloBoard.actions)
|
||||
) {
|
||||
await rimraf(inputs.file.fd);
|
||||
throw 'invalidFile';
|
||||
}
|
||||
|
||||
await rimraf(inputs.file.fd);
|
||||
|
||||
return trelloBoard;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,168 @@
|
||||
/*!
|
||||
* 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,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { isSubscribed, ...values } = inputs.values;
|
||||
|
||||
let board;
|
||||
if (_.isEmpty(values)) {
|
||||
board = inputs.record;
|
||||
} else {
|
||||
const scoper = sails.helpers.projects.makeScoper.with({
|
||||
record: inputs.project,
|
||||
});
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const boards = await Board.qm.getByProjectId(inputs.record.projectId, {
|
||||
exceptIdOrIds: inputs.record.id,
|
||||
});
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
boards,
|
||||
);
|
||||
|
||||
values.position = position;
|
||||
|
||||
if (repositions.length > 0) {
|
||||
await scoper.getUserIdsWithFullProjectVisibility();
|
||||
const clonedScoper = scoper.clone();
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await Board.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
projectId: reposition.record.projectId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
clonedScoper.replaceBoard(reposition.record);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const boardRelatedUserIds = await clonedScoper.getBoardRelatedUserIds();
|
||||
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
board = await Board.qm.updateOne(inputs.record.id, values);
|
||||
|
||||
if (!board) {
|
||||
return board;
|
||||
}
|
||||
|
||||
scoper.board = board;
|
||||
const boardRelatedUserIds = await scoper.getBoardRelatedUserIds();
|
||||
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardUpdate',
|
||||
{
|
||||
item: board,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
const webhooks = await Webhook.qm.getAll();
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
webhooks,
|
||||
event: Webhook.Events.BOARD_UPDATE,
|
||||
buildData: () => ({
|
||||
item: board,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
},
|
||||
}),
|
||||
buildPrevData: () => ({
|
||||
item: inputs.record,
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
if (!_.isUndefined(isSubscribed)) {
|
||||
const wasSubscribed = await sails.helpers.users.isBoardSubscriber(
|
||||
inputs.actorUser.id,
|
||||
board.id,
|
||||
);
|
||||
|
||||
if (isSubscribed !== wasSubscribed) {
|
||||
if (isSubscribed) {
|
||||
try {
|
||||
await BoardSubscription.qm.createOne({
|
||||
boardId: board.id,
|
||||
userId: inputs.actorUser.id,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.code !== 'E_UNIQUE') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await BoardSubscription.qm.deleteOne({
|
||||
boardId: board.id,
|
||||
userId: inputs.actorUser.id,
|
||||
});
|
||||
}
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`user:${inputs.actorUser.id}`,
|
||||
'boardUpdate',
|
||||
{
|
||||
item: {
|
||||
isSubscribed,
|
||||
id: board.id,
|
||||
},
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
|
||||
return board;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user