Fix modreport to include reports of deleted messages#286
Merged
Conversation
When a moderator deletes a message, it's now logged to both the per-user deletion thread and the moderation thread. This provides better visibility of mod actions in the moderation log alongside kicks, bans, and timeouts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The /modreport command was incorrectly filtering out all reports where the reported message had been deleted (deleted_at IS NOT NULL). This meant users who had messages reported and then deleted showed no moderation history. The deleted_at timestamp indicates the reported MESSAGE was deleted (a moderation action), not that the report should be hidden. These are actually the most important reports to show since they represent successful moderation. Removed the deleted_at filter from all modreport-related queries: - getUserReportStats (3 queries) - getSpamReportCount (1 query) - getUserReportSummary (6 queries) - getMonthlyReportCounts (1 query) - getRecentReportCount (2 queries) - getChannelBreakdown (1 query) - getStaffBreakdown (1 query) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Smoke Test Results
Tested commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/modreportcommand to include reports where the reported message was deleteddeleted_at IS NULLfilters from all modreport queriesProblem
The
/modreportcommand was returning "No moderation history found" for users who had messages that were reported and then deleted. For example, user393999891610861579had a spam report from 2026-02-16, but/modreportshowed no history.The issue was that all modreport queries filtered by
deleted_at IS NULL, excluding any reports where the reported message had been deleted. This is incorrect because:deleted_atindicates the reported message was deleted (a moderation action)Changes
Removed the
.where("deleted_at", "is", null)filter from 15 query locations inapp/models/reportedMessages.ts:getUserReportStats(3 queries)getSpamReportCount(1 query)getUserReportSummary(6 queries)getMonthlyReportCounts(1 query)getRecentReportCount(2 queries)getChannelBreakdown(1 query)getStaffBreakdown(1 query)Test plan
393999891610861579now appears in queries/modreportin production to confirm it shows previously hidden reports🤖 Generated with Claude Code