Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable setAutoArchiveDuration + isWeekend check #333

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions discord-scripts/thread-management/check-thread-archiving.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const THREAD_CHECK_CADENCE = 12 * HOUR // 12 * HOUR
// Use a ThreadAutoArchiveDuration as we'll still lean on Discord to
// auto-archive after issuing the warning, so we want the value to be
// one that we can update auto-archiving to.
// const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration = ThreadAutoArchiveDuration.OneDay
const AUTO_ARCHIVE_WARNING_LEAD_MINUTES: ThreadAutoArchiveDuration =
ThreadAutoArchiveDuration.OneDay

// Let's grab if it's the weekend, 0 = sunday, 6 = saturday
const isWeekend = (): boolean => [0, 6].includes(new Date().getDay())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also thinking about holidays here, rough stuff. I wonder if we avoid Mondays as well for that reason 🤔


/**
* A helper to request follow-up action on a thread based on the id of the user
Expand Down Expand Up @@ -369,6 +373,11 @@ async function checkThreadStatus(
robot: Robot,
discordClient: Client,
): Promise<void> {
if (isWeekend()) {
robot.logger.info("Skipping thread status checks on the weekend.")
return
}

const threadMetadataByThreadId = getAllThreadMetadata(robot.brain)

Object.entries(threadMetadataByThreadId)
Expand Down Expand Up @@ -474,7 +483,8 @@ async function checkThreadStatus(
},
],
})

// Let's add back setting the thread autoArchive to 24hr after the message is sent
await thread.setAutoArchiveDuration(AUTO_ARCHIVE_WARNING_LEAD_MINUTES)
// Use robot brain to store the warning event data
robot.brain.set(warningKey, warningMessage.id)
robot.logger.info(
Expand Down
Loading