mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 15:38:59 +00:00
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:
parent
8b65ce3053
commit
18bd3f8c54
2 changed files with 7 additions and 3 deletions
|
|
@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue