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

23 lines
608 B
JavaScript
Raw Normal View History

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
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 Notification.qm.getUnreadByUserId(currentUser.id);
2019-08-31 04:07:25 +05:00
const userIds = sails.helpers.utils.mapRecords(notifications, 'creatorUserId', true, true);
const users = await User.qm.getByIds(userIds);
2019-08-31 04:07:25 +05:00
return {
2019-08-31 04:07:25 +05:00
items: notifications,
included: {
users: sails.helpers.users.presentMany(users, currentUser),
},
};
},
2019-08-31 04:07:25 +05:00
};