mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
send correct email when user is removed from group plan
This commit is contained in:
@@ -861,7 +861,7 @@ api.removeGroupMember = {
|
||||
group.memberCount -= 1;
|
||||
if (group.hasNotCancelled()) {
|
||||
await group.updateGroupPlan(true);
|
||||
await payments.cancelGroupSubscriptionForUser(member, group);
|
||||
await payments.cancelGroupSubscriptionForUser(member, group, true);
|
||||
}
|
||||
|
||||
if (group.quest && group.quest.leader === member._id) {
|
||||
|
||||
@@ -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},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user