Implement the atrocity that is filtering out inactivity notices that cannot be actioned

This commit is contained in:
regalijan 2023-10-19 16:50:51 -04:00
parent 8435cbdcb2
commit 8cc3f58ca2
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -63,6 +63,26 @@ export async function onRequestGet(context: RequestContext) {
if (item) {
delete item.user?.email;
if (entryType === "inactivity") {
// Only include inactivity notices that a user can actually act on
const departments = {
DM: [1 << 11],
ET: [1 << 4, 1 << 12],
FM: [1 << 7],
WM: [1 << 6],
};
if (
!Object.entries(departments).find(
(dept) =>
item.departments.includes(dept[0]) &&
dept[1].find((p) => currentUser.permissions & p),
)
)
continue;
}
items.push({ ...item, id });
}
}