Skip to content

Explain custom purge timing, resume interrupted wipes, and add message lifetimes - #46

Merged
BoxingOctopus merged 1 commit into
mainfrom
patch/timed_channel_purge_scheduling
Dec 4, 2026
Merged

BoxingOctopus merged 1 commit into
mainfrom
patch/timed_channel_purge_scheduling

Conversation

@BoxingOctopus

Copy link
Copy Markdown
Contributor

Why

Admins reported custom purge schedules firing early. A */15 * * * * schedule wiped 5 minutes after saving, and a daily schedule wiped a few hours after saving.

The scheduler is correct. Cron schedules run at fixed times on the UTC clock, not counted from the save. Saving */15 at :40 fires at :45. A midnight UTC schedule fires at 7 PM Eastern. The panel showed a single "Next wipe" time with no explanation, so the first run looked wrong.

What changed

Clearer custom schedules

  • The cron field shows the next three wipe times in local time as you type. An invalid cron shows its error instead.
  • Saved custom schedules show the next wipe plus the two after it.
  • The cron help explains clock-based timing, using */15 as the example.
  • New read-only endpoint: GET /api/guilds/:guildID/purges/preview?cron=...

Interrupted wipes resume

At startup, RecoverStuckWork used to reset running wipes and set them to run again right away. That threw away the saved position and wiped the whole channel again. Running wipes now stay as they are, and the scheduler continues from the saved position.

Message lifetime (new)

Pick a channel and a lifetime: 15 minutes, 1 hour, 4 hours, 24 hours, or 7 days. The bot deletes each message that long after it was posted. Messages already in the channel count too.

  • Discord message IDs encode the post time. Each check asks Discord only for messages posted before now - lifetime, so there's no per-message tracking table. Messages posted while the bot was offline get deleted on the next check.
  • Each channel gets a check about once a minute, with up to 1,000 deletions per check.
  • Follows the same rules as timed wipes: pinned and bot messages go, and messages older than 14 days stay.
  • Uses the existing "Timed purge on" switch.
  • A failed check records the error and waits 15 minutes before retrying. A deleted channel shows as gone.
  • One lifetime per channel. Saving again replaces it and resets the removed count.
  • New table: 023_channel_expiries.sql
  • New routes: POST /purges/lifetimes, DELETE /purges/lifetimes/:channelID

Test mock

The Discord mock now gives messages time-based IDs, like real Discord. The lifetime sweep depends on this. All existing tests pass with the change.

Testing

  • go test ./...
  • go test -tags e2e ./e2e, with new tests for the cron preview, resume after restart (fails on the old code), and the lifetime API and sweeps (expired, fresh, older than 14 days, paging, paused, missing channel)
  • Full Playwright suite, 31 passing, including the new preview and Message Lifetime flows

Notes

  • svelte-check reports one existing error in web/vite.config.js (missing Node types for process). This PR doesn't touch it.

@BoxingOctopus BoxingOctopus added the release:patch Fix: bump the patch version (the default) label Dec 4, 2026
@BoxingOctopus
BoxingOctopus merged commit fb3cc23 into main Dec 4, 2026
6 checks passed
@BoxingOctopus
BoxingOctopus deleted the patch/timed_channel_purge_scheduling branch December 4, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:patch Fix: bump the patch version (the default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant