send correct email when user is removed from group plan

This commit is contained in:
Matteo Pagliazzi
2017-12-04 12:04:07 +01:00
parent 470495387c
commit 72f0b8ed7c
2 changed files with 5 additions and 3 deletions

View File

@@ -235,7 +235,7 @@ api.cancelGroupUsersSubscription = async function cancelGroupUsersSubscription (
await Promise.all(promises);
};
api.cancelGroupSubscriptionForUser = async function cancelGroupSubscriptionForUser (user, group) {
api.cancelGroupSubscriptionForUser = async function cancelGroupSubscriptionForUser (user, group, userWasRemoved = false) {
if (user.purchased.plan.customerId !== this.constants.GROUP_PLAN_CUSTOMER_ID) return;
let userGroups = user.guilds.toObject();
@@ -256,7 +256,9 @@ api.cancelGroupSubscriptionForUser = async function cancelGroupSubscriptionForUs
if (userGroupPlans.length === 0) {
let leader = await User.findById(group.leader).exec();
txnEmail(user, 'group-member-cancel', [
const email = userWasRemoved ? 'group-member-removed' : 'group-member-cancel';
txnEmail(user, email, [
{name: 'LEADER', content: leader.profile.name},
{name: 'GROUP_NAME', content: group.name},
]);