overleaf/services/web/app/src/Features/Subscription/SubscriptionEmailHandler.js
Timothée Alby f771119cb1 Merge pull request #7712 from overleaf/jpa-email-copy-changes
[web] make copy changes to trial onboarding email

GitOrigin-RevId: 027ba8d471c0cac56dff7c56135d091a96817cf3
2022-04-26 08:04:31 +00:00

26 lines
773 B
JavaScript

const EmailHandler = require('../Email/EmailHandler')
const UserGetter = require('../User/UserGetter')
require('./SubscriptionEmailBuilder')
const PlansLocator = require('./PlansLocator')
const SubscriptionEmailHandler = {
async sendTrialOnboardingEmail(userId, planCode) {
const user = await UserGetter.promises.getUser(userId, {
email: 1,
})
const plan = PlansLocator.findLocalPlanInSettings(planCode)
if (!plan) {
throw new Error('unknown paid plan: ' + planCode)
}
const emailOptions = {
to: user.email,
sendingUser_id: userId,
planName: plan.name,
features: plan.features,
}
await EmailHandler.promises.sendEmail('trialOnboarding', emailOptions)
},
}
module.exports = SubscriptionEmailHandler