mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #4057 from overleaf/msm-prevent-onboarding-email-server-pro
Prevented Onboarding email from being sent in CE/SP GitOrigin-RevId: 68d117b477bd90c6410aabdcc6af8142626f7b4e
This commit is contained in:
@@ -8,6 +8,7 @@ const UserGetter = require('./UserGetter')
|
||||
const UserUpdater = require('./UserUpdater')
|
||||
const Analytics = require('../Analytics/AnalyticsManager')
|
||||
const UserOnboardingEmailQueueManager = require('./UserOnboardingEmailManager')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
||||
async function _addAffiliation(user, affiliationOptions) {
|
||||
try {
|
||||
@@ -24,8 +25,10 @@ async function _addAffiliation(user, affiliationOptions) {
|
||||
user = await UserGetter.promises.getUser(user._id)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ userId: user._id, email: user.email },
|
||||
'could not get fresh user data'
|
||||
OError.tag(error, 'could not get fresh user data', {
|
||||
userId: user._id,
|
||||
email: user.email,
|
||||
})
|
||||
)
|
||||
}
|
||||
return user
|
||||
@@ -73,22 +76,26 @@ async function createNewUser(attributes, options = {}) {
|
||||
} catch (error) {
|
||||
if (options.requireAffiliation) {
|
||||
await UserDeleter.promises.deleteMongoUser(user._id)
|
||||
throw error
|
||||
throw OError.tag(error)
|
||||
} else {
|
||||
logger.error(error)
|
||||
logger.error(OError.tag(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Analytics.recordEvent(user._id, 'user-registered')
|
||||
Analytics.setUserProperty(user._id, 'created-at', new Date())
|
||||
try {
|
||||
await UserOnboardingEmailQueueManager.scheduleOnboardingEmail(user)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Failed to schedule sending of onboarding email for user '${user._id}'`,
|
||||
error
|
||||
)
|
||||
|
||||
if (Features.hasFeature('saas')) {
|
||||
try {
|
||||
await UserOnboardingEmailQueueManager.scheduleOnboardingEmail(user)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
OError.tag(error, 'Failed to schedule sending of onboarding email', {
|
||||
userId: user._id,
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return user
|
||||
|
||||
@@ -279,7 +279,8 @@ describe('UserCreator', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it('should schedule an onboarding email on registration', async function () {
|
||||
it('should schedule an onboarding email on registration with saas feature', async function () {
|
||||
this.Features.hasFeature = sinon.stub().withArgs('saas').returns(true)
|
||||
const user = await this.UserCreator.promises.createNewUser({
|
||||
email: this.email,
|
||||
})
|
||||
@@ -289,6 +290,14 @@ describe('UserCreator', function () {
|
||||
user
|
||||
)
|
||||
})
|
||||
|
||||
it('should not add schedule onboarding email when without saas feature', async function () {
|
||||
const attributes = { email: this.email }
|
||||
await this.UserCreator.promises.createNewUser(attributes)
|
||||
sinon.assert.notCalled(
|
||||
this.UserOnboardingEmailManager.scheduleOnboardingEmail
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user