From 18bd3f8c54f67492a7745e6285aec81f2fc23214 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Thu, 9 Mar 2017 19:11:21 -0600 Subject: [PATCH] Send group plans subscription message to Slack (#8549) * feat(Slack): send group plans sub message * fix(Slack): grab more relevant user data --- website/server/libs/payments.js | 7 ++++--- website/server/libs/slack.js | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/website/server/libs/payments.js b/website/server/libs/payments.js index 6ea848c73d..4f2d6df15a 100644 --- a/website/server/libs/payments.js +++ b/website/server/libs/payments.js @@ -56,9 +56,9 @@ function _dateDiff (earlyDate, lateDate) { api.addSubscriptionToGroupUsers = async function addSubscriptionToGroupUsers (group) { let members; if (group.type === 'guild') { - members = await User.find({guilds: group._id}).select('_id purchased items').exec(); + members = await User.find({guilds: group._id}).select('_id purchased items auth profile.name').exec(); } else { - members = await User.find({'party._id': group._id}).select('_id purchased items').exec(); + members = await User.find({'party._id': group._id}).select('_id purchased items auth profile.name').exec(); } let promises = members.map((member) => { @@ -379,7 +379,8 @@ api.createSubscription = async function createSubscription (data) { email: getUserInfo(data.gift.member, ['email']).email, } : {}, paymentMethod: data.paymentMethod, - months, + months: group ? 1 : months, + groupId, }); }; diff --git a/website/server/libs/slack.js b/website/server/libs/slack.js index f195c02199..dd60f84a2c 100644 --- a/website/server/libs/slack.js +++ b/website/server/libs/slack.js @@ -69,6 +69,7 @@ function sendSubscriptionNotification ({ recipient, paymentMethod, months, + groupId, }) { if (!SLACK_SUBSCRIPTIONS_URL) { return; @@ -77,6 +78,8 @@ function sendSubscriptionNotification ({ let 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}`; + } else if (groupId) { + text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`; } else { text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month recurring subscription using ${paymentMethod} on ${timestamp}`; }