fix: enforce community ownership on earnings withdrawal#832
Conversation
The withdrawEarnings action looked up the community only by the id taken from the callback data, without checking that the caller actually owns it. Scope the lookup by creator_id as well, matching the other community management handlers (deleteCommunity, changeVisibility, updateCommunity), so only the community creator can start a withdrawal of its earnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR adds an authorization check to the ChangesCommunity Creator Authorization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. 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. Comment |
What
The
withdrawEarningsaction looked up the target community using only the id taken from the inline-button callback data, without verifying that the caller owns that community. This change scopes the lookup bycreator_idas well, so only the community creator can start a withdrawal of its earnings.Why
Every other community-management handler (
deleteCommunity,changeVisibility,updateCommunity) already filters bycreator_id: ctx.user._id. The earnings-withdrawal path was the only one missing that ownership check, leaving it inconsistent with the rest of the module. Scoping the query keeps authorization consistent across all community operations.Change
bot/modules/community/actions.ts— addcreator_id: ctx.user._idto theCommunity.findOnelookup inwithdrawEarnings.Testing
npx tsc --noEmitpasses.npx eslint bot/modules/community/actions.tspasses.Summary by CodeRabbit