From c2593893ef2c697d5a421166863811405bca8282 Mon Sep 17 00:00:00 2001 From: Manjunath Basavaraj Bhadrannavar Date: Sat, 25 Oct 2025 08:24:41 +0200 Subject: [PATCH 1/2] disable schedules --- src/main.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index c8f59d0..59c162e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,6 +25,8 @@ await load({ export: true }); const HTTP_ONLY = (Deno.env.get("HTTP_ONLY") ?? "").toLowerCase() === "1" || (Deno.env.get("HTTP_ONLY") ?? "").toLowerCase() === "true"; +const ENABLE_SCHEDULES = (Deno.env.get("ENABLE_SCHEDULES") ?? "").toLowerCase() === "1" || + (Deno.env.get("ENABLE_SCHEDULES") ?? "").toLowerCase() === "true"; const appToken = Deno.env.get("SLACK_APP_TOKEN"); const botToken = Deno.env.get("SLACK_BOT_TOKEN"); @@ -154,7 +156,15 @@ if (!HTTP_ONLY) { } case "join": { if (args[1] === "every") { - await application.joinSchedule({ weekday: args[2], user, channel }); + if (ENABLE_SCHEDULES) { + await application.joinSchedule({ weekday: args[2], user, channel }); + } else { + await webClient.chat.postEphemeral({ + user: body.user_id, + channel, + text: "Don't be a :sloth: and join the session at 9 AM!", + }); + } break; } await application.joinSession({ dateString: args[1], user, channel }); @@ -225,6 +235,17 @@ if (!HTTP_ONLY) { await socketModeClient!.start(); } +// Purge existing schedules only when schedules are disabled +if (!ENABLE_SCHEDULES) { + const schedules = await level.scheduleRepository.loadAllSchedules(); + if (schedules.length > 0) { + for (const s of schedules) { + await level.scheduleRepository.deleteSchedule(s.user); + } + expressLogger.info(`Purged ${schedules.length} existing schedules`); + } +} + await application.start(); const logger = new Logger("Express"); From b404ccb6d8b58ae2ec51d8f1cb4953aa222a6adf Mon Sep 17 00:00:00 2001 From: Manjunath Basavaraj Bhadrannavar Date: Sat, 25 Oct 2025 08:28:20 +0200 Subject: [PATCH 2/2] disable schedules --- src/main.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 59c162e..7fb59da 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,7 +25,8 @@ await load({ export: true }); const HTTP_ONLY = (Deno.env.get("HTTP_ONLY") ?? "").toLowerCase() === "1" || (Deno.env.get("HTTP_ONLY") ?? "").toLowerCase() === "true"; -const ENABLE_SCHEDULES = (Deno.env.get("ENABLE_SCHEDULES") ?? "").toLowerCase() === "1" || +const ENABLE_SCHEDULES = + (Deno.env.get("ENABLE_SCHEDULES") ?? "").toLowerCase() === "1" || (Deno.env.get("ENABLE_SCHEDULES") ?? "").toLowerCase() === "true"; const appToken = Deno.env.get("SLACK_APP_TOKEN"); @@ -157,12 +158,16 @@ if (!HTTP_ONLY) { case "join": { if (args[1] === "every") { if (ENABLE_SCHEDULES) { - await application.joinSchedule({ weekday: args[2], user, channel }); + await application.joinSchedule({ + weekday: args[2], + user, + channel, + }); } else { await webClient.chat.postEphemeral({ user: body.user_id, channel, - text: "Don't be a :sloth: and join the session at 9 AM!", + text: "Stop being a :sloth: and join the session at 9 AM!", }); } break;