1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/controllers/notifications/index.js

25 lines
726 B
JavaScript
Executable file

module.exports = {
async fn() {
const { currentUser } = this.req;
const notifications = await sails.helpers.users.getNotifications(currentUser.id);
const actionIds = sails.helpers.utils.mapRecords(notifications, 'actionId');
const actions = await sails.helpers.actions.getMany(actionIds);
const userIds = sails.helpers.utils.mapRecords(actions, 'userId', true);
const users = await sails.helpers.users.getMany(userIds, true);
const cardIds = sails.helpers.utils.mapRecords(notifications, 'cardId');
const cards = await sails.helpers.cards.getMany(cardIds);
return {
items: notifications,
included: {
users,
cards,
actions,
},
};
},
};