Send group plans subscription message to Slack (#8549)

* feat(Slack): send group plans sub message

* fix(Slack): grab more relevant user data
This commit is contained in:
Sabe Jones 2017-03-09 19:11:21 -06:00 committed by GitHub
parent 8b65ce3053
commit 18bd3f8c54
2 changed files with 7 additions and 3 deletions

View file

@ -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,
});
};

View file

@ -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}`;
}