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,
{

View File

@@ -3,6 +3,7 @@ import { IncomingWebhook } from '@slack/webhook';
import nconf from 'nconf';
import moment from 'moment';
import logger from './logger';
import { getCurrentEvent } from './worldState'; // eslint-disable-line import/no-cycle
import { TAVERN_ID } from '../models/group'; // eslint-disable-line import/no-cycle
const SLACK_FLAGGING_URL = nconf.get('SLACK_FLAGGING_URL');
@@ -188,7 +189,9 @@ function sendSubscriptionNotification ({
let text;
const timestamp = new Date();
if (recipient.id) {
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email} using ${paymentMethod} on ${timestamp}`;
const currentEvent = getCurrentEvent();
const promoString = currentEvent && currentEvent.promo && currentEvent.promo ? ' and got a promo' : '';
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email}${promoString} using ${paymentMethod} on ${timestamp}`;
} else if (groupId) {
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
} else {