From 8cc3f58ca20f0eedc0a1f20ea1cdf3308004cc67 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:51 -0400 Subject: [PATCH] Implement the atrocity that is filtering out inactivity notices that cannot be actioned --- functions/api/mod-queue/list.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions/api/mod-queue/list.ts b/functions/api/mod-queue/list.ts index 4871af8..169e375 100644 --- a/functions/api/mod-queue/list.ts +++ b/functions/api/mod-queue/list.ts @@ -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 }); } }