2025-05-10 02:09:06 +02:00
|
|
|
/*!
|
|
|
|
* Copyright (c) 2024 PLANKA Software GmbH
|
|
|
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
|
|
|
*/
|
|
|
|
|
|
|
|
const { idInput } = require('../../../utils/inputs');
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
const Errors = {
|
|
|
|
NOTIFICATION_NOT_FOUND: {
|
|
|
|
notificationNotFound: 'Notification not found',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
id: {
|
2025-05-10 02:09:06 +02:00
|
|
|
...idInput,
|
2021-06-24 01:05:22 +05:00
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
exits: {
|
|
|
|
notificationNotFound: {
|
|
|
|
responseType: 'notFound',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
async fn(inputs) {
|
|
|
|
const { currentUser } = this.req;
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const notification = await Notification.qm.getOneById(inputs.id, {
|
2021-06-24 01:05:22 +05:00
|
|
|
userId: currentUser.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!notification) {
|
|
|
|
throw Errors.NOTIFICATION_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const users = notification.creatorUserId
|
|
|
|
? await User.qm.getByIds([notification.creatorUserId])
|
|
|
|
: [];
|
2021-06-24 01:05:22 +05:00
|
|
|
|
|
|
|
return {
|
|
|
|
item: notification,
|
|
|
|
included: {
|
2025-05-10 02:09:06 +02:00
|
|
|
users,
|
2021-06-24 01:05:22 +05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|