feat(event): Winter Wonderland 2021 and Gift-One-Get-One Promotion

This commit is contained in:
Sabe Jones
2020-12-10 16:53:37 -06:00
parent 74ebcf919e
commit 53f19c4da3
282 changed files with 681 additions and 198 deletions

View File

@@ -18,6 +18,7 @@ import {
import shared from '../../../common';
import { sendNotification as sendPushNotification } from '../pushNotifications'; // eslint-disable-line import/no-cycle
import calculateSubscriptionTerminationDate from './calculateSubscriptionTerminationDate';
import { getCurrentEvent } from '../worldState'; // eslint-disable-line import/no-cycle
// @TODO: Abstract to shared/constant
const JOINED_GROUP_PLAN = 'joined group plan';
@@ -243,6 +244,23 @@ async function createSubscription (data) {
// Only send push notifications if sending to a user other than yourself
if (data.gift.member._id !== data.user._id) {
const currentEvent = getCurrentEvent();
if (currentEvent && currentEvent.promo && currentEvent.promo === 'g1g1') {
const promoData = {
user: data.user,
gift: {
member: data.user,
subscription: {
key: data.gift.subscription.key,
},
},
paymentMethod: data.paymentMethod,
promo: 'Winter',
promoUsername: data.gift.member.auth.local.username,
};
await this.createSubscription(promoData);
}
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
sendPushNotification(data.gift.member,
{