mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Revert "WIP: Buy-1-Get-1 Gift Subs (#9719)"
This reverts commit dc3d694d0e, with the exception of locale strings that need not be purged.
This commit is contained in:
@@ -365,59 +365,47 @@ api.createSubscription = async function createSubscription (data) {
|
||||
txnEmail(data.user, emailType);
|
||||
}
|
||||
|
||||
if (!data.promo) {
|
||||
analytics.trackPurchase({
|
||||
uuid: data.user._id,
|
||||
groupId,
|
||||
itemPurchased,
|
||||
sku: `${data.paymentMethod.toLowerCase()}-subscription`,
|
||||
purchaseType,
|
||||
paymentMethod: data.paymentMethod,
|
||||
quantity: 1,
|
||||
gift: Boolean(data.gift),
|
||||
purchaseValue: block.price,
|
||||
headers: data.headers,
|
||||
});
|
||||
}
|
||||
analytics.trackPurchase({
|
||||
uuid: data.user._id,
|
||||
groupId,
|
||||
itemPurchased,
|
||||
sku: `${data.paymentMethod.toLowerCase()}-subscription`,
|
||||
purchaseType,
|
||||
paymentMethod: data.paymentMethod,
|
||||
quantity: 1,
|
||||
gift: Boolean(data.gift),
|
||||
purchaseValue: block.price,
|
||||
headers: data.headers,
|
||||
});
|
||||
|
||||
if (!group && !data.promo) data.user.purchased.txnCount++;
|
||||
if (!group) data.user.purchased.txnCount++;
|
||||
|
||||
if (data.gift) {
|
||||
let byUserName = getUserInfo(data.user, ['name']).name;
|
||||
|
||||
// generate the message in both languages, so both users can understand it
|
||||
let languages = [data.user.preferences.language, data.gift.member.preferences.language];
|
||||
if (data.promo) {
|
||||
let senderMsg = shared.i18n.t(`giftedSubscription${data.promo}Promo`, {
|
||||
username: data.gift.member.profile.name,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[0]);
|
||||
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[0]);
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
data.user.sendMessage(data.gift.member, { senderMsg });
|
||||
} else {
|
||||
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[0]);
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
let receiverMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[1]);
|
||||
receiverMsg = `\`${receiverMsg}\``;
|
||||
|
||||
let receiverMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[1]);
|
||||
receiverMsg = `\`${receiverMsg}\``;
|
||||
|
||||
if (data.gift.message) {
|
||||
receiverMsg += ` ${data.gift.message}`;
|
||||
senderMsg += ` ${data.gift.message}`;
|
||||
}
|
||||
|
||||
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg });
|
||||
if (data.gift.message) {
|
||||
receiverMsg += ` ${data.gift.message}`;
|
||||
senderMsg += ` ${data.gift.message}`;
|
||||
}
|
||||
|
||||
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg });
|
||||
|
||||
if (data.gift.member.preferences.emailNotifications.giftedSubscription !== false) {
|
||||
txnEmail(data.gift.member, 'gifted-subscription', [
|
||||
{name: 'GIFTER', content: byUserName},
|
||||
@@ -425,20 +413,7 @@ api.createSubscription = async function createSubscription (data) {
|
||||
]);
|
||||
}
|
||||
|
||||
if (data.gift.member._id !== data.user._id) { // If sending to a user other than yourself, don't push notify, and get bonus sub for self per holiday promo
|
||||
let promoData = {
|
||||
user: data.user,
|
||||
gift: {
|
||||
member: data.user,
|
||||
subscription: {
|
||||
key: data.gift.subscription.key,
|
||||
},
|
||||
},
|
||||
paymentMethod: data.paymentMethod,
|
||||
promo: 'Winter',
|
||||
};
|
||||
await this.createSubscription(promoData);
|
||||
|
||||
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
||||
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
||||
sendPushNotification(data.gift.member,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user