Skip to content

fix: enforce content moderation on doubt and reply edits (#474)#499

Closed
vedant7007 wants to merge 1 commit into
knoxiboy:mainfrom
vedant7007:fix/edit-moderation-bypass-474
Closed

fix: enforce content moderation on doubt and reply edits (#474)#499
vedant7007 wants to merge 1 commit into
knoxiboy:mainfrom
vedant7007:fix/edit-moderation-bypass-474

Conversation

@vedant7007

@vedant7007 vedant7007 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

User description

Closes #474

doubt and reply creation ran moderateContent() + handleModerationViolation() before persisting, but the edit paths skipped moderation entirely. users could post clean content then edit in abusive material bypassing the 3-strike system.

what i fixed:

  • doubts/action/[id]/route.ts: added moderateContent check in the edit action before db.update(), matching the POST handler pattern
  • replies/action/[id]/route.ts: same moderation check in PATCH handler before building updateData

edge cases: subject-only or imageUrl-only edits skip moderation (no text to check). null/empty content skips moderation but edit still proceeds. strikes increment correctly through existing handleModerationViolation flow.

for labels i think gssoc:approved + level:advanced + type:security + quality:clean fits here. happy to make changes if needed!


CodeAnt-AI Description

Block moderated content from being saved in doubt and reply edits

What Changed

  • Editing a doubt or reply now checks the new text before saving it
  • If the edited text violates moderation rules, the edit is rejected with an error instead of being applied
  • Empty text and non-text-only edits still proceed without a moderation check

Impact

✅ Fewer abusive edits slipping through
✅ Stronger moderation on post updates
✅ Safer community replies and doubts

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Jun 1, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@vedant7007, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 39 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ba8e3a76-c3f9-4e90-aea4-a73743a2251f

📥 Commits

Reviewing files that changed from the base of the PR and between 99d5b8b and b1045a3.

📒 Files selected for processing (2)
  • src/app/api/doubts/action/[id]/route.ts
  • src/app/api/replies/action/[id]/route.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added gssoc'26 GSSoC program issue level:advanced Advanced level task type:bug Bug fix size/xs labels Jun 1, 2026
@github-actions
github-actions Bot requested a review from knoxiboy June 1, 2026 14:13
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

@coderabbitai review

1 similar comment
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

@coderabbitai review

@codeant-ai

codeant-ai Bot commented Jun 1, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@vedant7007 vedant7007 closed this Jun 1, 2026
@github-actions github-actions Bot added invalid This doesn't seem right and removed gssoc'26 GSSoC program issue level:advanced Advanced level task type:bug Bug fix size/s review-needed labels Jun 1, 2026
@knoxiboy knoxiboy reopened this Jun 6, 2026
@github-actions github-actions Bot added size/xs gssoc'26 GSSoC program issue level:advanced Advanced level task type:bug Bug fix review-needed labels Jun 6, 2026
@knoxiboy knoxiboy removed the invalid This doesn't seem right label Jun 6, 2026
@knoxiboy knoxiboy closed this Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc'26 GSSoC program issue level:advanced Advanced level task type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Doubt and reply edit actions completely bypass AI content moderation — users can edit in abusive material

2 participants