1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 21:29:43 +02:00
planka/server/api/controllers/notifications/index.js

26 lines
726 B
JavaScript
Raw Normal View History

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