From c5e5e3bb7151a80210595c9df62a1e02b5f4828e Mon Sep 17 00:00:00 2001 From: Adrian Winterstein Date: Thu, 19 Jun 2025 07:39:03 +0200 Subject: [PATCH] Disables payment for group plans. --- .../group-plans/groupPlanCreationModal.vue | 65 +++++++++++-------- .../src/components/groups/rightSidebar.vue | 2 + .../src/components/static/groupPlans.vue | 32 --------- website/server/controllers/api-v3/groups.js | 18 ++++- website/server/models/group.js | 13 ++-- 5 files changed, 61 insertions(+), 69 deletions(-) diff --git a/website/client/src/components/group-plans/groupPlanCreationModal.vue b/website/client/src/components/group-plans/groupPlanCreationModal.vue index 1ad1e64682..2af39d7fdd 100644 --- a/website/client/src/components/group-plans/groupPlanCreationModal.vue +++ b/website/client/src/components/group-plans/groupPlanCreationModal.vue @@ -20,11 +20,11 @@

{{ $t('createGroup') }}

@@ -75,32 +75,13 @@ >{{ $t('leaderOnlyChallenges') }} -
- - -
@@ -227,14 +208,15 @@ diff --git a/website/client/src/components/groups/rightSidebar.vue b/website/client/src/components/groups/rightSidebar.vue index 0418f2403c..e9cb616137 100644 --- a/website/client/src/components/groups/rightSidebar.vue +++ b/website/client/src/components/groups/rightSidebar.vue @@ -31,6 +31,7 @@ > + {{ $t('groupPlanDesc') }}

-
- Just - $9 - per month + - $3 - per additional member* -
-

- {{ $t('billedMonthly') }} -

@@ -69,18 +59,6 @@

{{ $t('groupManagementControlsDesc') }}

-
- -

- {{ $t('inGameBenefits') }} -

-

- {{ $t('inGameBenefitsDesc') }} -

-
@@ -96,13 +74,6 @@ > {{ $t('createGroupToday') }} -
- Just - $9 - per month + - $3 - per member* -
-

- {{ $t('billedMonthly') }} -

diff --git a/website/server/controllers/api-v3/groups.js b/website/server/controllers/api-v3/groups.js index e66b9711ef..8827f19aad 100644 --- a/website/server/controllers/api-v3/groups.js +++ b/website/server/controllers/api-v3/groups.js @@ -197,8 +197,6 @@ api.createGroupPlan = { const { user } = res.locals; const group = new Group(Group.sanitize(req.body.groupToCreate)); - req.checkBody('paymentType', res.t('paymentTypeRequired')).notEmpty(); - req.checkBody('summary', apiError('summaryLengthExceedsMax')).isLength({ max: MAX_SUMMARY_SIZE_FOR_GUILDS }); const validationErrors = req.validationErrors(); if (validationErrors) throw validationErrors; @@ -208,6 +206,18 @@ api.createGroupPlan = { user.guilds.push(group._id); const results = await Promise.all([user.save(), group.save()]); + + await payments.createSubscription({ + user, + customerId: 'habitrpg', + paymentMethod: '', + sub: { + key: 'group_monthly', + quantity: 100000, + }, + groupId: group._id, + }); + const savedGroup = results[1]; res.analytics.track('join group', { @@ -264,6 +274,8 @@ api.createGroupPlan = { headers, }); + res.respond(201, groupResponse); + } else { res.respond(201, groupResponse); } }, @@ -492,9 +504,11 @@ api.updateGroup = { if (group.leader !== user._id && group.type === 'party') throw new NotAuthorized(res.t('messageGroupOnlyLeaderCanUpdate')); else if (group.leader !== user._id && !user.hasPermission('moderator')) throw new NotAuthorized(res.t('messageGroupOnlyLeaderCanUpdate')); + /* if (req.body.leader && req.body.leader !== user._id && group.hasNotCancelled()) { throw new NotAuthorized(res.t('cannotChangeLeaderWithActiveGroupPlan')); } + */ const handleArrays = (currentValue, updatedValue) => { if (!_.isArray(currentValue)) { diff --git a/website/server/models/group.js b/website/server/models/group.js index 7d181c818e..27a0d8a3c6 100644 --- a/website/server/models/group.js +++ b/website/server/models/group.js @@ -1,4 +1,3 @@ -import moment from 'moment'; import mongoose from 'mongoose'; import _ from 'lodash'; import validator from 'validator'; @@ -1354,6 +1353,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC const group = this; const update = {}; + /* if (group.memberCount <= 1 && group.privacy === 'private' && group.hasNotCancelled()) { throw new NotAuthorized(shared.i18n.t('cannotDeleteActiveGroup')); } @@ -1361,6 +1361,7 @@ schema.methods.leave = async function leaveGroup (user, keep = 'keep-all', keepC if (group.leader === user._id && group.hasNotCancelled()) { throw new NotAuthorized(shared.i18n.t('leaderCannotLeaveGroupWithActiveGroup')); } + */ if (group.purchased.plan.customerId) { await payments.cancelGroupSubscriptionForUser(user, this); @@ -1635,20 +1636,16 @@ schema.methods.checkChatSpam = function groupCheckChatSpam (user) { }; schema.methods.hasActiveGroupPlan = function hasActiveGroupPlan () { - const now = new Date(); const { plan } = this.purchased; - return plan && plan.customerId - && (!plan.dateTerminated || moment(plan.dateTerminated).isAfter(now)); + return plan && plan.customerId; }; schema.methods.hasNotCancelled = function hasNotCancelled () { - const { plan } = this.purchased; - return Boolean(this.hasActiveGroupPlan() && !plan.dateTerminated); + return this.hasActiveGroupPlan(); }; schema.methods.hasCancelled = function hasCancelled () { - const { plan } = this.purchased; - return Boolean(this.hasActiveGroupPlan() && plan.dateTerminated); + return !this.hasActiveGroupPlan(); }; schema.methods.updateGroupPlan = async function updateGroupPlan (removingMember) {