Update group plan eligibility check
This commit is contained in:
@@ -395,11 +395,11 @@ export default {
|
||||
return this.userGuilds.filter(group => {
|
||||
const leaderId = group.leader?._id || group.leader;
|
||||
if (leaderId !== this.user._id) return false;
|
||||
const plan = group.purchased?.plan;
|
||||
if (!plan?.customerId) return false;
|
||||
const purchased = group.purchased;
|
||||
if (!purchased?.wasUpgraded) return false;
|
||||
if (this.activeGroupPlanIds.includes(group._id)) return false;
|
||||
if (!plan.dateTerminated) return false;
|
||||
return new Date(plan.dateTerminated) < new Date();
|
||||
if (!purchased.dateTerminated) return false;
|
||||
return new Date(purchased.dateTerminated) < new Date();
|
||||
});
|
||||
},
|
||||
upgradeableParty () {
|
||||
|
||||
@@ -156,7 +156,17 @@ schema.plugin(baseModel, {
|
||||
noSet: ['_id', 'balance', 'quest', 'memberCount', 'chat', 'bannedWordsAllowed', 'challengeCount', 'tasksOrder', 'purchased', 'managers'],
|
||||
private: ['purchased.plan'],
|
||||
toJSONTransform (plainObj, originalDoc) {
|
||||
if (plainObj.purchased) plainObj.purchased.active = originalDoc.hasActiveGroupPlan();
|
||||
if (plainObj.purchased) {
|
||||
plainObj.purchased.active = originalDoc.hasActiveGroupPlan();
|
||||
// Expose non-sensitive plan info for upgrade flow
|
||||
const plan = originalDoc.purchased?.plan;
|
||||
if (plan?.customerId) {
|
||||
plainObj.purchased.wasUpgraded = true;
|
||||
if (plan.dateTerminated) {
|
||||
plainObj.purchased.dateTerminated = plan.dateTerminated;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user