mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
[web] Add extra details to flexible license sales email (#32929)
* [web] Add extra details to flexible license sales email GitOrigin-RevId: fbd41adae21c55c5e97f9531565100e1ae911808
This commit is contained in:
@@ -2,6 +2,7 @@ import SubscriptionGroupHandler from './SubscriptionGroupHandler.mjs'
|
||||
|
||||
import OError from '@overleaf/o-error'
|
||||
import logger from '@overleaf/logger'
|
||||
import Settings from '@overleaf/settings'
|
||||
import SubscriptionLocator from './SubscriptionLocator.mjs'
|
||||
import SessionManager from '../Authentication/SessionManager.mjs'
|
||||
import UserAuditLogHandler from '../User/UserAuditLogHandler.mjs'
|
||||
@@ -312,7 +313,7 @@ async function submitForm(req, res) {
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
const userEmail = await UserGetter.promises.getUserEmail(userId)
|
||||
|
||||
const { paymentProviderSubscription } =
|
||||
const { paymentProviderSubscription, subscription } =
|
||||
await SubscriptionGroupHandler.promises.getUsersGroupSubscriptionDetails(
|
||||
userId
|
||||
)
|
||||
@@ -327,9 +328,19 @@ async function submitForm(req, res) {
|
||||
const messageLines = [`\n**Overleaf Sales Contact Form:**`]
|
||||
messageLines.push('**Subject:** Self-Serve Group User Increase Request')
|
||||
messageLines.push(`**Estimated Number of Users:** ${adding}`)
|
||||
messageLines.push(
|
||||
`**Subscription:** [${subscription._id}](${Settings.adminUrl}/admin/subscription/${subscription._id})`
|
||||
)
|
||||
messageLines.push(`**Current Number of Seats:** ${subscription.membersLimit}`)
|
||||
messageLines.push(`**Plan Code:** ${subscription.planCode}`)
|
||||
if (poNumber) {
|
||||
messageLines.push(`**PO Number:** ${poNumber}`)
|
||||
}
|
||||
if (subscription.salesforce_id) {
|
||||
messageLines.push(
|
||||
`**Salesforce ID:** [${subscription.salesforce_id}](https://digitalscience.lightning.force.com/lightning/r/Opportunity/${subscription.salesforce_id}/view)`
|
||||
)
|
||||
}
|
||||
messageLines.push(
|
||||
`**Message:** This email has been generated on behalf of user with email **${userEmail}** ` +
|
||||
'to request an increase in the total number of users for their subscription.'
|
||||
|
||||
@@ -28,6 +28,7 @@ describe('SubscriptionGroupController', function () {
|
||||
teamName: 'Cool group',
|
||||
groupPlan: true,
|
||||
membersLimit: 5,
|
||||
planCode: 'group_collaborator_10',
|
||||
}
|
||||
|
||||
ctx.plan = {
|
||||
@@ -212,6 +213,10 @@ describe('SubscriptionGroupController', function () {
|
||||
() => ctx.SubscriptionModel
|
||||
)
|
||||
|
||||
vi.doMock('@overleaf/settings', () => ({
|
||||
default: { adminUrl: 'https://admin.overleaf.com' },
|
||||
}))
|
||||
|
||||
vi.doMock('@overleaf/logger', () => ({
|
||||
default: {
|
||||
err: sinon.stub(),
|
||||
@@ -786,6 +791,12 @@ describe('SubscriptionGroupController', function () {
|
||||
'\n' +
|
||||
`**Estimated Number of Users:** ${adding}\n` +
|
||||
'\n' +
|
||||
`**Subscription:** [${ctx.subscriptionId}](https://admin.overleaf.com/admin/subscription/${ctx.subscriptionId})\n` +
|
||||
'\n' +
|
||||
`**Current Number of Seats:** ${ctx.subscription.membersLimit}\n` +
|
||||
'\n' +
|
||||
`**Plan Code:** ${ctx.subscription.planCode}\n` +
|
||||
'\n' +
|
||||
`**PO Number:** ${poNumber}\n` +
|
||||
'\n' +
|
||||
`**Message:** This email has been generated on behalf of user with email **${ctx.user.email}** to request an increase in the total number of users for their subscription.`,
|
||||
@@ -800,6 +811,27 @@ describe('SubscriptionGroupController', function () {
|
||||
ctx.Controller.submitForm(ctx.req, res, resolve)
|
||||
})
|
||||
})
|
||||
|
||||
it('should include the Salesforce ID line when the subscription has a salesforce_id', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
const adding = 100
|
||||
const salesforceId = '0061x000ABCDEFG'
|
||||
ctx.subscription.salesforce_id = salesforceId
|
||||
ctx.req.body = { adding }
|
||||
|
||||
const res = {
|
||||
sendStatus: () => {
|
||||
const { message } =
|
||||
ctx.Modules.promises.hooks.fire.getCall(0).args[1]
|
||||
message.should.include(
|
||||
`**Salesforce ID:** [${salesforceId}](https://digitalscience.lightning.force.com/lightning/r/Opportunity/${salesforceId}/view)\n`
|
||||
)
|
||||
resolve()
|
||||
},
|
||||
}
|
||||
ctx.Controller.submitForm(ctx.req, res, resolve)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('subscriptionUpgradePage', function () {
|
||||
|
||||
Reference in New Issue
Block a user