mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Gift Subscriptions Promo (#8270)
* WIP(promo): buy-1-get-1 subs * WIP(subscriptions): Slack integration * feat(Slack): notify on sub buy
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from './errors';
|
||||
import slack from './slack';
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -171,6 +172,21 @@ api.createSubscription = async function createSubscription (data) {
|
||||
}
|
||||
|
||||
if (data.gift) await data.gift.member.save();
|
||||
|
||||
slack.sendSubscriptionNotification({
|
||||
buyer: {
|
||||
id: data.user._id,
|
||||
name: data.user.profile.name,
|
||||
email: getUserInfo(data.user, ['email']).email,
|
||||
},
|
||||
recipient: data.gift ? {
|
||||
id: data.gift.member._id,
|
||||
name: data.gift.member.profile.name,
|
||||
email: getUserInfo(data.gift.member, ['email']).email,
|
||||
} : {},
|
||||
paymentMethod: data.paymentMethod,
|
||||
months,
|
||||
});
|
||||
};
|
||||
|
||||
// Sets their subscription to be cancelled later
|
||||
|
||||
Reference in New Issue
Block a user