Skip to content

Commit 5d0cae2

Browse files
grunchclaude
andauthored
fix: enforce community ownership on earnings withdrawal (#832)
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>
1 parent 084c0da commit 5d0cae2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

bot/modules/community/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,13 @@ export const onSetCommunity = async (ctx: CommunityContext) => {
128128

129129
export const withdrawEarnings = async (ctx: CommunityContext) => {
130130
ctx.deleteMessage();
131+
// Only the community creator may withdraw its earnings. The community id
132+
// comes from the callback data, so we scope the lookup by creator_id to
133+
// match the other community-management handlers (deleteCommunity,
134+
// changeVisibility, updateCommunity).
131135
const community = await Community.findOne({
132136
_id: ctx.match?.[1],
137+
creator_id: ctx.user._id,
133138
enabled: { $ne: false },
134139
});
135140
if (!community) return ctx.reply(ctx.i18n.t('community_not_found'));

0 commit comments

Comments
 (0)