-
Notifications
You must be signed in to change notification settings - Fork 128
feat: implement community inactive status validation system #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -298,7 +298,10 @@ const deleteOrderFromChannel = async (order: IOrder, telegram: Telegram) => { | |||||||||||||||||
| try { | ||||||||||||||||||
| let channel = process.env.CHANNEL; | ||||||||||||||||||
| if (order.community_id) { | ||||||||||||||||||
| const community = await Community.findOne({ _id: order.community_id }); | ||||||||||||||||||
| const community = await Community.findOne({ | ||||||||||||||||||
| _id: order.community_id, | ||||||||||||||||||
| active: true, | ||||||||||||||||||
| }); | ||||||||||||||||||
| if (!community) { | ||||||||||||||||||
| return channel; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -321,7 +324,10 @@ const deleteOrderFromChannel = async (order: IOrder, telegram: Telegram) => { | |||||||||||||||||
| const getOrderChannel = async (order: IOrder) => { | ||||||||||||||||||
| let channel = process.env.CHANNEL; | ||||||||||||||||||
| if (order.community_id) { | ||||||||||||||||||
| const community = await Community.findOne({ _id: order.community_id }); | ||||||||||||||||||
| const community = await Community.findOne({ | ||||||||||||||||||
| _id: order.community_id, | ||||||||||||||||||
| active: true, | ||||||||||||||||||
| }); | ||||||||||||||||||
| if (!community) { | ||||||||||||||||||
| return channel; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -342,7 +348,10 @@ const getOrderChannel = async (order: IOrder) => { | |||||||||||||||||
| const getDisputeChannel = async (order: IOrder) => { | ||||||||||||||||||
| let channel = process.env.DISPUTE_CHANNEL; | ||||||||||||||||||
| if (order.community_id) { | ||||||||||||||||||
| const community = await Community.findOne({ _id: order.community_id }); | ||||||||||||||||||
| const community = await Community.findOne({ | ||||||||||||||||||
| _id: order.community_id, | ||||||||||||||||||
| active: true, | ||||||||||||||||||
| }); | ||||||||||||||||||
| if (community === null) throw Error('Community was not found in DB'); | ||||||||||||||||||
| channel = community.dispute_channel; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -454,7 +463,7 @@ const getFee = async ( | |||||||||||||||||
| // Calculate fees | ||||||||||||||||||
| const botFee = maxFee * Number(process.env.FEE_PERCENT); | ||||||||||||||||||
| let communityFee = Math.round(maxFee - botFee); | ||||||||||||||||||
| const community = await Community.findOne({ _id: communityId }); | ||||||||||||||||||
| const community = await Community.findOne({ _id: communityId, active: true }); | ||||||||||||||||||
| if (community === null) throw Error('Community was not found in DB'); | ||||||||||||||||||
| communityFee = communityFee * (community.fee / 100); | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+466
to
469
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fee calc should treat inactive as “no community” instead of throwing. Throwing propagates to order flows. Return the global-fee path when inactive/missing. - const community = await Community.findOne({ _id: communityId, active: true });
- if (community === null) throw Error('Community was not found in DB');
- communityFee = communityFee * (community.fee / 100);
+ const community = await Community.findOne({ _id: communityId, active: true });
+ if (!community) {
+ return isGoldenHoneyBadger ? 0 : maxFee;
+ }
+ communityFee = communityFee * (community.fee / 100);Run: npm run format 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Differentiate “not found” vs “inactive” on /setcomm
Right now inactive communities fall through as “not found”. Prefer explicit feedback using community_inactive.
Also applies to: 57-59
🤖 Prompt for AI Agents