refs #4797 refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-05-11 07:18:58 +02:00
parent 9cb756544e
commit 33ef9bdf61
1 changed files with 12 additions and 10 deletions

View File

@ -43,6 +43,11 @@ module.exports = Self => {
} }
}, myOptions); }, myOptions);
const activeNotifications = await models.NotificationSubscription.find({
include: {relation: 'notification'},
where: {userFk: id}
}, myOptions);
for (acl of availableNotifications) { for (acl of availableNotifications) {
notifications.set(acl.notificationFk, { notifications.set(acl.notificationFk, {
id: null, id: null,
@ -53,17 +58,14 @@ module.exports = Self => {
}); });
} }
const activeNotifications = await models.NotificationSubscription.find({
include: {relation: 'notification'},
where: {userFk: id}
}, myOptions);
for (subscription of activeNotifications) { for (subscription of activeNotifications) {
const notification = notifications.get(subscription.notificationFk); notifications.set(subscription.notificationFk, {
if (notification) { id: subscription.id,
notification.active = true; notificationFk: subscription.notificationFk,
notification.id = subscription.id; name: subscription.notification().name,
} description: subscription.notification().description,
active: true,
});
} }
return [...notifications.values()]; return [...notifications.values()];