mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Merge branch 'release' into develop
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "habitica",
|
"name": "habitica",
|
||||||
"version": "4.249.3",
|
"version": "4.249.4",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "habitica",
|
"name": "habitica",
|
||||||
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
|
"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",
|
"main": "./website/server/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.19.6",
|
"@babel/core": "^7.19.6",
|
||||||
|
|||||||
@@ -417,7 +417,6 @@ describe('Apple Payments', () => {
|
|||||||
|
|
||||||
it('errors when a user is using the same subscription', async () => {
|
it('errors when a user is using the same subscription', async () => {
|
||||||
user = new User();
|
user = new User();
|
||||||
user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
await user.save();
|
await user.save();
|
||||||
payments.createSubscription.restore();
|
payments.createSubscription.restore();
|
||||||
|
|
||||||
@@ -431,8 +430,6 @@ describe('Apple Payments', () => {
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
await applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing);
|
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))
|
await expect(applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing))
|
||||||
.to.eventually.be.rejected.and.to.eql({
|
.to.eventually.be.rejected.and.to.eql({
|
||||||
|
|||||||
@@ -370,10 +370,6 @@ describe('payments/index', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context('Purchasing a subscription for self', () => {
|
context('Purchasing a subscription for self', () => {
|
||||||
beforeEach(() => {
|
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('creates a subscription', async () => {
|
it('creates a subscription', async () => {
|
||||||
expect(user.purchased.plan.planId).to.not.exist;
|
expect(user.purchased.plan.planId).to.not.exist;
|
||||||
|
|
||||||
@@ -400,7 +396,6 @@ describe('payments/index', () => {
|
|||||||
user.purchased.plan = plan;
|
user.purchased.plan = plan;
|
||||||
user.purchased.plan.dateTerminated = moment(new Date()).add(2, 'months');
|
user.purchased.plan.dateTerminated = moment(new Date()).add(2, 'months');
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(0);
|
expect(user.purchased.plan.extraMonths).to.eql(0);
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
@@ -411,7 +406,6 @@ describe('payments/index', () => {
|
|||||||
user.purchased.plan = plan;
|
user.purchased.plan = plan;
|
||||||
user.purchased.plan.dateTerminated = moment(new Date()).subtract(2, 'months');
|
user.purchased.plan.dateTerminated = moment(new Date()).subtract(2, 'months');
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(0);
|
expect(user.purchased.plan.extraMonths).to.eql(0);
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
@@ -421,7 +415,6 @@ describe('payments/index', () => {
|
|||||||
it('does not reset Gold-to-Gems cap on additional subscription', async () => {
|
it('does not reset Gold-to-Gems cap on additional subscription', async () => {
|
||||||
user.purchased.plan = plan;
|
user.purchased.plan = plan;
|
||||||
user.purchased.plan.gemsBought = 10;
|
user.purchased.plan.gemsBought = 10;
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
@@ -558,10 +551,6 @@ describe('payments/index', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context('Block subscription perks', () => {
|
context('Block subscription perks', () => {
|
||||||
beforeEach(() => {
|
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds block months to plan.consecutive.offset', async () => {
|
it('adds block months to plan.consecutive.offset', async () => {
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
@@ -598,7 +587,6 @@ describe('payments/index', () => {
|
|||||||
data.sub.key = 'basic_12mo';
|
data.sub.key = 'basic_12mo';
|
||||||
|
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
expect(user.purchased.plan.consecutive.gemCapExtra).to.eql(25);
|
expect(user.purchased.plan.consecutive.gemCapExtra).to.eql(25);
|
||||||
@@ -765,7 +753,6 @@ describe('payments/index', () => {
|
|||||||
now: mayMysteryItemTimeframe,
|
now: mayMysteryItemTimeframe,
|
||||||
toFake: ['Date'],
|
toFake: ['Date'],
|
||||||
});
|
});
|
||||||
data.user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { // eslint-disable-line import/no-cycle
|
|||||||
import {
|
import {
|
||||||
NotAuthorized,
|
NotAuthorized,
|
||||||
NotFound,
|
NotFound,
|
||||||
TooManyRequests,
|
|
||||||
} from '../errors';
|
} from '../errors';
|
||||||
import shared from '../../../common';
|
import shared from '../../../common';
|
||||||
import { sendNotification as sendPushNotification } from '../pushNotifications'; // eslint-disable-line import/no-cycle
|
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 emailType = 'subscription-begins';
|
||||||
let recipientIsSubscribed = recipient.isSubscribed();
|
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 we are buying a group subscription
|
||||||
if (data.groupId) {
|
if (data.groupId) {
|
||||||
const groupFields = basicGroupFields.concat(' purchased');
|
const groupFields = basicGroupFields.concat(' purchased');
|
||||||
|
|||||||
Reference in New Issue
Block a user