mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-04-26 01:49:23 -05:00
Added admin email notifications to tier system
This commit is contained in:
parent
880691b928
commit
d36f9eaa98
|
|
@ -16,7 +16,8 @@
|
||||||
"stripe": {
|
"stripe": {
|
||||||
"goal_cents": 300000,
|
"goal_cents": 300000,
|
||||||
"secret_key": "secret_key",
|
"secret_key": "secret_key",
|
||||||
"webhook_secret": "webhook_secret"
|
"webhook_secret": "webhook_secret",
|
||||||
|
"notification_emails": []
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
"account": {
|
"account": {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ const PNIDSchema = new Schema({
|
||||||
},
|
},
|
||||||
server_access_level: String,
|
server_access_level: String,
|
||||||
access_level: Number,
|
access_level: Number,
|
||||||
|
username: String,
|
||||||
connections: {
|
connections: {
|
||||||
discord: {
|
discord: {
|
||||||
id: String
|
id: String
|
||||||
|
|
|
||||||
39
src/util.js
39
src/util.js
|
|
@ -400,6 +400,19 @@ async function handleStripeEvent(event) {
|
||||||
assignDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
assignDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
||||||
logger.error(`Error assigning user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
logger.error(`Error assigning user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const email of config.stripe.notification_emails) {
|
||||||
|
// * Send notification emails for new sub
|
||||||
|
try {
|
||||||
|
await mailer.sendMail({
|
||||||
|
to: email,
|
||||||
|
subject: `[Pretendo] - New ${product.name} subscription`,
|
||||||
|
text: `${pnid.get('username')} just became a ${product.name} tier subscriber`
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subscription.status === 'canceled') {
|
if (subscription.status === 'canceled') {
|
||||||
|
|
@ -416,6 +429,19 @@ async function handleStripeEvent(event) {
|
||||||
removeDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
removeDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
||||||
logger.error(`Error removing user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
logger.error(`Error removing user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const email of config.stripe.notification_emails) {
|
||||||
|
// * Send notification emails for new sub
|
||||||
|
try {
|
||||||
|
await mailer.sendMail({
|
||||||
|
to: email,
|
||||||
|
subject: `[Pretendo] - Canceled ${product.name} subscription`,
|
||||||
|
text: `${pnid.get('username')} just canceled their ${product.name} tier subscription`
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subscription.status === 'unpaid') {
|
if (subscription.status === 'unpaid') {
|
||||||
|
|
@ -432,6 +458,19 @@ async function handleStripeEvent(event) {
|
||||||
removeDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
removeDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
||||||
logger.error(`Error removing user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
logger.error(`Error removing user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const email of config.stripe.notification_emails) {
|
||||||
|
// * Send notification emails for new sub
|
||||||
|
try {
|
||||||
|
await mailer.sendMail({
|
||||||
|
to: email,
|
||||||
|
subject: `[Pretendo] - Removed ${product.name} subscription`,
|
||||||
|
text: `${pnid.get('username')}'s ${product.name} tier subscription has been canceled due to non payment`
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user