Repository navigation
feat(purge): delete messages older than 14 days too - #394
Ferdinand99 wants to merge 4 commits into
Conversation
/purge now deletes messages of any age. On Discord, messages younger than 14 days are bulk-deleted and older ones are deleted one at a time at the platform's pace, waiting out 429s. Fluxer's bulk route has no age limit, so everything goes through it there. A long purge shows progress with a Stop button (the person who ran it and server admins), one purge runs per channel at a time, and the final reply reports deleted and failed counts.
There was a problem hiding this comment.
Graphify code review 
Review completed · 7668584b97b2
Tip
Merge confidence: 5/5 · Looks safe to merge · ⚪ Medium impact
No issues reported
The purge command now handles older messages with paced single deletes, while retaining bulk deletion for eligible messages.
Full summary
The purge command now handles older messages with paced single deletes, while retaining bulk deletion for eligible messages. It also adds progress updates, a Stop button for longer Discord purges, and a per-channel lock.
What this review covered
- We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
- 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 45 functions depend on this change
Impact & health
Impact — 45 functions depend on the 45 functions this change touches.
Health — this change adds coupling hotspots:
- new:
purgeMessages()— 3 callers, 6 callees
Formal checks — 45 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Health delta baseline: last indexed commit a9ec8af (diverged from this PR's base — delta is approximate).
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 45 function(s) in the blast radius were not formally verified this run
Test selection
674 of 674 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
noncode-change,uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
apps/sylo-ios/SyloKit/Tests/SyloKitTests/Access/DashboardAccessTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Access/Round3Tests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/AccountConnectTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/AccountModelTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/ConnectCallbackSourceTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/NoDashboardLinkSourceTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Appeals/AppealsReviewTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationFormsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationPassthroughTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationSubmissionsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationWireTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Audit/AuditHistoryTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Audit/AuditLogTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/CallbackIssuerAddressTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/CallbackIssuerTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/KeychainTokenStoreTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/PKCETests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/SignInRequestTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/TokenStoreTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Changelog/ChangelogTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Commands/CommandOverridesTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/CollectiblePictureTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/EconomyAdminTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/EconomyMembersTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/InventoryTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopExtrasTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopItemsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopModelTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Embeds/EmbedDraftTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Embeds/ModuleLimitsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Events/CommunityReviewFixesTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Events/EventEndpointsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Giveaways/GiveawayActionsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/GuildSettings/CommandPrefixTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/GuildSettings/GuildSettingsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Health/HealthTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Import/P6Tests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Insights/InsightsTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Leaderboard/LeaderboardTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Members/MemberDataTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Members/MemberSearchTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Messages/ComposedMessagesModelTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Messages/ComposedMessagesTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/ModelDecodingTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/ServerListTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/Sylo52PolishTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/UnknownKeysTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/Utf16TextLimitTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/Moderation/ModerationTests.swift— full-run-safetyapps/sylo-ios/SyloKit/Tests/SyloKitTests/ModuleSettings/AfkSettingsTests.swift— full-run-safety- … and 624 more
⚠️ non-code file(s) changed (docs/modules/moderation.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
⚠️ changed code file(s) with no mapped test (docs/modules/moderation.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Every flagged function
purgeMessages()insrc/bot/lib/purgeMessages.js:148· 3 callers, 6 callees: fans out to 6 callees (efferent coupling)
…keep old pinned messages - end the run as timed out instead of waiting past the 15-minute interaction token - post the mod-log entry before the final reply and tolerate a failing reply - the progress reply is ephemeral, so only the person who ran the command can stop it; drop the server-admin wording - keep pinned messages older than 14 days, as before, and say how many were kept
What
/purgeusedchannel.bulkDelete(messages, true), which silently skipped messages older than 14 days. It now deletes messages of any age.retry_after) and the same message is retried, up to 5 times; a message that keeps failing is counted as failed. A bulk error "too old" (50034) or a message the bulk call skipped falls back to single deletes.fluxer_apiPOST /channels/:id/messages/bulk-delete(MessageDeleteService.bulkDeleteMessages) has no age limit, takes 1-100 ids, and only needs Manage Messages. So on Fluxer every message goes through the bulk route (filterOld = false). The route is limited to 10 requests per 10 s per channel, the single delete to 20 per 10 s, so the single-delete fallback there is paced at 550 ms./purgein the same channel is refused with a clear message until the first finishes or is stopped (lock keyed byguildKey()+ channel id, released infinally).docs/modules/moderation.mdno longer say "younger than 14 days".Tests
New
test/purgeCommand.test.js(32 tests): split by age, single-delete pacing with fake 429s (both SDKs' error shapes), failure classification, stop button permissions, one-at-a-time lock, Fluxer path and the compat adapter, the 100 cap, and the command flow.Lint, prettier, and the full SQLite and Postgres 16 suites pass.