mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-17 09:22:19 +00:00
Merge branch 'apple_sub_fix' of https://github.com/HabitRPG/habitica into apple_sub_fix
# Conflicts: # test/api/unit/libs/payments/apple.test.js # website/server/libs/payments/subscriptions.js
This commit is contained in:
commit
87aebcc19e
1 changed files with 16 additions and 0 deletions
|
|
@ -116,6 +116,22 @@ async function prepareSubscriptionValues (data) {
|
|||
let recipientIsSubscribed = recipient.isSubscribed();
|
||||
let isNewSubscription = !recipientIsSubscribed
|
||||
|
||||
if (data.user && !data.gift && !data.groupId) {
|
||||
const unlockedUser = await User.findOneAndUpdate(
|
||||
{
|
||||
_id: data.user._id,
|
||||
$or: [
|
||||
{ _subSignature: 'NOT_RUNNING' },
|
||||
{ _subSignature: { $exists: false } },
|
||||
],
|
||||
},
|
||||
{ $set: { _subSignature: 'SUB_IN_PROGRESS' } },
|
||||
);
|
||||
if (!unlockedUser) {
|
||||
throw new NotFound('User not found or subscription already processing.');
|
||||
}
|
||||
}
|
||||
|
||||
// If we are buying a group subscription
|
||||
if (data.groupId) {
|
||||
const groupFields = basicGroupFields.concat(' purchased');
|
||||
|
|
|
|||
Loading…
Reference in a new issue