mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-22 20:52:02 +00:00
hooked up lifetime emails
This commit is contained in:
parent
a9327cb7c5
commit
ffe690afa3
4 changed files with 18 additions and 4 deletions
|
@ -4,7 +4,7 @@ EmailSender = require "./EmailSender"
|
|||
|
||||
module.exports =
|
||||
|
||||
sendEmail : (emailType, opts, callback)->
|
||||
sendEmail : (emailType, opts, callback = (err)->)->
|
||||
email = EmailBuilder.buildEmail emailType, opts
|
||||
if email.type == "lifecycle" and !settings.email.lifecycle
|
||||
return callback()
|
||||
|
|
|
@ -2,9 +2,10 @@ RecurlyWrapper = require("./RecurlyWrapper")
|
|||
Settings = require "settings-sharelatex"
|
||||
User = require('../../models/User').User
|
||||
logger = require('logger-sharelatex')
|
||||
AnalyticsManager = require '../../Features/Analytics/AnalyticsManager'
|
||||
AnalyticsManager = require '../Analytics/AnalyticsManager'
|
||||
SubscriptionUpdater = require("./SubscriptionUpdater")
|
||||
LimitationsManager = require('./LimitationsManager')
|
||||
EmailHandler = require("../Email/EmailHandler")
|
||||
|
||||
module.exports =
|
||||
|
||||
|
@ -33,6 +34,10 @@ module.exports =
|
|||
RecurlyWrapper.cancelSubscription subscription.recurlySubscription_id, (error) ->
|
||||
return callback(error) if error?
|
||||
AnalyticsManager.trackSubscriptionCancelled user
|
||||
emailOpts =
|
||||
to: user.email
|
||||
first_name: user.first_name
|
||||
EmailHandler.sendEmail "canceledSubscription", emailOpts
|
||||
callback()
|
||||
else
|
||||
callback()
|
||||
|
@ -55,4 +60,3 @@ module.exports =
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -86,6 +86,10 @@ module.exports =
|
|||
#things that can be fired and forgot.
|
||||
newsLetterManager.subscribe user
|
||||
ReferalAllocator.allocate req.session.referal_id, user._id, req.session.referal_source, req.session.referal_medium
|
||||
emailOpts =
|
||||
first_name:user.first_name
|
||||
to: user.email
|
||||
EmailHandler.sendEmail "welcome", emailOpts
|
||||
|
||||
requestPasswordReset : (req, res)->
|
||||
res.render 'user/passwordReset',
|
||||
|
|
|
@ -57,14 +57,17 @@ describe "Subscription Handler sanboxed", ->
|
|||
userHasSubscription: sinon.stub()
|
||||
userHasSubscriptionOrFreeTrial: sinon.stub()
|
||||
|
||||
@EmailHandler =
|
||||
sendEmail:sinon.stub()
|
||||
@SubscriptionHandler = SandboxedModule.require modulePath, requires:
|
||||
"./RecurlyWrapper": @RecurlyWrapper
|
||||
"settings-sharelatex": @Settings
|
||||
'../../models/User': User:@User
|
||||
'./SubscriptionUpdater': @SubscriptionUpdater
|
||||
'../../Features/Analytics/AnalyticsManager': @AnalyticsManager
|
||||
'../Analytics/AnalyticsManager': @AnalyticsManager
|
||||
"logger-sharelatex":{log:->}
|
||||
'./LimitationsManager':@LimitationsManager
|
||||
"../Email/EmailHandler":@EmailHandler
|
||||
|
||||
@SubscriptionHandler.syncSubscriptionToUser = sinon.stub().callsArgWith(2)
|
||||
|
||||
|
@ -150,6 +153,9 @@ describe "Subscription Handler sanboxed", ->
|
|||
.calledWith(@user)
|
||||
.should.equal true
|
||||
|
||||
it "should send a cancellation email", ->
|
||||
@EmailHandler.sendEmail.calledWith("canceledSubscription", {to:@user.email, first_name:@user.first_name}).should.equal true
|
||||
|
||||
describe "reactiveRecurlySubscription", ->
|
||||
describe "with a user without a subscription", ->
|
||||
beforeEach (done) ->
|
||||
|
|
Loading…
Reference in a new issue