diff --git a/package-lock.json b/package-lock.json index f32e964fc8..bc0cf3c6e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "habitica", - "version": "4.249.3", + "version": "4.249.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 733e862d4a..01397b7025 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "habitica", "description": "A habit tracker app which treats your goals like a Role Playing Game.", - "version": "4.249.3", + "version": "4.249.4", "main": "./website/server/index.js", "dependencies": { "@babel/core": "^7.19.6", diff --git a/test/api/unit/libs/payments/apple.test.js b/test/api/unit/libs/payments/apple.test.js index e11c3bd86f..32f662d22d 100644 --- a/test/api/unit/libs/payments/apple.test.js +++ b/test/api/unit/libs/payments/apple.test.js @@ -417,7 +417,6 @@ describe('Apple Payments', () => { it('errors when a user is using the same subscription', async () => { user = new User(); - user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); await user.save(); payments.createSubscription.restore(); @@ -431,8 +430,6 @@ describe('Apple Payments', () => { }]); await applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing); - user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); - await user.save(); await expect(applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing)) .to.eventually.be.rejected.and.to.eql({ diff --git a/test/api/unit/libs/payments/payments.test.js b/test/api/unit/libs/payments/payments.test.js index 16af9e6e15..84475e4b0e 100644 --- a/test/api/unit/libs/payments/payments.test.js +++ b/test/api/unit/libs/payments/payments.test.js @@ -370,10 +370,6 @@ describe('payments/index', () => { }); context('Purchasing a subscription for self', () => { - beforeEach(() => { - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); - }); - it('creates a subscription', async () => { expect(user.purchased.plan.planId).to.not.exist; @@ -400,7 +396,6 @@ describe('payments/index', () => { user.purchased.plan = plan; user.purchased.plan.dateTerminated = moment(new Date()).add(2, 'months'); expect(user.purchased.plan.extraMonths).to.eql(0); - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); await api.createSubscription(data); @@ -411,7 +406,6 @@ describe('payments/index', () => { user.purchased.plan = plan; user.purchased.plan.dateTerminated = moment(new Date()).subtract(2, 'months'); expect(user.purchased.plan.extraMonths).to.eql(0); - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); await api.createSubscription(data); @@ -421,7 +415,6 @@ describe('payments/index', () => { it('does not reset Gold-to-Gems cap on additional subscription', async () => { user.purchased.plan = plan; user.purchased.plan.gemsBought = 10; - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); await api.createSubscription(data); @@ -558,10 +551,6 @@ describe('payments/index', () => { }); context('Block subscription perks', () => { - beforeEach(() => { - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); - }); - it('adds block months to plan.consecutive.offset', async () => { await api.createSubscription(data); @@ -598,7 +587,6 @@ describe('payments/index', () => { data.sub.key = 'basic_12mo'; await api.createSubscription(data); - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); await api.createSubscription(data); expect(user.purchased.plan.consecutive.gemCapExtra).to.eql(25); @@ -765,7 +753,6 @@ describe('payments/index', () => { now: mayMysteryItemTimeframe, toFake: ['Date'], }); - data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate(); }); afterEach(() => { diff --git a/website/server/libs/payments/subscriptions.js b/website/server/libs/payments/subscriptions.js index 733b9ba76f..75a49312e2 100644 --- a/website/server/libs/payments/subscriptions.js +++ b/website/server/libs/payments/subscriptions.js @@ -16,7 +16,6 @@ import { // eslint-disable-line import/no-cycle import { NotAuthorized, NotFound, - TooManyRequests, } from '../errors'; import shared from '../../../common'; import { sendNotification as sendPushNotification } from '../pushNotifications'; // eslint-disable-line import/no-cycle @@ -92,12 +91,6 @@ async function prepareSubscriptionValues (data) { let emailType = 'subscription-begins'; let recipientIsSubscribed = recipient.isSubscribed(); - if (data.user && !data.gift && !data.groupId && data.customerId !== 'group-plan') { - if (moment().diff(data.user.purchased.plan.dateUpdated, 'minutes') < 3) { - throw new TooManyRequests('Subscription already processed, likely duplicate request'); - } - } - // If we are buying a group subscription if (data.groupId) { const groupFields = basicGroupFields.concat(' purchased');