mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 22:59:44 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
48
server/api/controllers/notifications/show.js
Normal file
48
server/api/controllers/notifications/show.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const Errors = {
|
||||
NOTIFICATION_NOT_FOUND: {
|
||||
notificationNotFound: 'Notification not found',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
id: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
notificationNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const notification = await Notification.findOne({
|
||||
id: inputs.id,
|
||||
isRead: false,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
if (!notification) {
|
||||
throw Errors.NOTIFICATION_NOT_FOUND;
|
||||
}
|
||||
|
||||
const action = await Action.findOne(notification.actionId);
|
||||
const user = await sails.helpers.users.getOne(action.userId, true);
|
||||
const card = await Card.findOne(notification.cardId);
|
||||
|
||||
return {
|
||||
item: notification,
|
||||
included: {
|
||||
users: [user],
|
||||
cards: [card],
|
||||
actions: [action],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue