mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #328 from sharelatex/sk-plain-text-email
Sk plain text email
This commit is contained in:
commit
95a66bbf00
7 changed files with 76 additions and 7 deletions
|
@ -104,7 +104,7 @@ module.exports = CollaboratorsInviteHandler =
|
||||||
return callback(null)
|
return callback(null)
|
||||||
CollaboratorsInviteHandler._sendMessages projectId, sendingUser, invite, (err) ->
|
CollaboratorsInviteHandler._sendMessages projectId, sendingUser, invite, (err) ->
|
||||||
if err?
|
if err?
|
||||||
logger.err {projectid, inviteId}, "error resending invite messages"
|
logger.err {projectId, inviteId}, "error resending invite messages"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
callback(null)
|
callback(null)
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,15 @@ templates.projectInvite =
|
||||||
subject: _.template "<%= project.name %> - shared by <%= owner.email %>"
|
subject: _.template "<%= project.name %> - shared by <%= owner.email %>"
|
||||||
layout: NotificationEmailLayout
|
layout: NotificationEmailLayout
|
||||||
type:"notification"
|
type:"notification"
|
||||||
|
plainTextTemplate: _.template """
|
||||||
|
Hi, <%= owner.email %> wants to share '<%= project.name %>' with you.
|
||||||
|
|
||||||
|
Follow this link to view the project: <%= inviteUrl %>
|
||||||
|
|
||||||
|
Thank you
|
||||||
|
|
||||||
|
#{settings.appName} - <%= siteUrl %>
|
||||||
|
"""
|
||||||
compiledTemplate: _.template """
|
compiledTemplate: _.template """
|
||||||
<p>Hi, <%= owner.email %> wants to share <a href="<%= project.url %>">'<%= project.name %>'</a> with you</p>
|
<p>Hi, <%= owner.email %> wants to share <a href="<%= project.url %>">'<%= project.name %>'</a> with you</p>
|
||||||
<center>
|
<center>
|
||||||
|
@ -137,5 +146,6 @@ module.exports =
|
||||||
return {
|
return {
|
||||||
subject : template.subject(opts)
|
subject : template.subject(opts)
|
||||||
html: template.layout(opts)
|
html: template.layout(opts)
|
||||||
|
text: template?.plainTextTemplate?(opts)
|
||||||
type:template.type
|
type:template.type
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ module.exports =
|
||||||
if email.type == "lifecycle" and !settings.email.lifecycle
|
if email.type == "lifecycle" and !settings.email.lifecycle
|
||||||
return callback()
|
return callback()
|
||||||
opts.html = email.html
|
opts.html = email.html
|
||||||
|
opts.text = email.text
|
||||||
opts.subject = email.subject
|
opts.subject = email.subject
|
||||||
EmailSender.sendEmail opts, (err)->
|
EmailSender.sendEmail opts, (err)->
|
||||||
callback(err)
|
callback(err)
|
|
@ -49,6 +49,7 @@ module.exports =
|
||||||
from: defaultFromAddress
|
from: defaultFromAddress
|
||||||
subject: options.subject
|
subject: options.subject
|
||||||
html: options.html
|
html: options.html
|
||||||
|
text: options.text
|
||||||
replyTo: options.replyTo || Settings.email.replyToAddress
|
replyTo: options.replyTo || Settings.email.replyToAddress
|
||||||
socketTimeout: 30 * 1000
|
socketTimeout: 30 * 1000
|
||||||
client.sendMail options, (err, res)->
|
client.sendMail options, (err, res)->
|
||||||
|
|
|
@ -34,6 +34,31 @@ describe "EmailBuilder", ->
|
||||||
@email.html.indexOf(@opts.owner.email).should.not.equal -1
|
@email.html.indexOf(@opts.owner.email).should.not.equal -1
|
||||||
@email.subject.indexOf(@opts.owner.email).should.not.equal -1
|
@email.subject.indexOf(@opts.owner.email).should.not.equal -1
|
||||||
|
|
||||||
|
it 'should not have text component', ->
|
||||||
|
expect(@email.html?).to.equal true
|
||||||
|
expect(@email.text?).to.equal false
|
||||||
|
|
||||||
|
it "should not have undefined in it", ->
|
||||||
|
@email.html.indexOf("undefined").should.equal -1
|
||||||
|
@email.subject.indexOf("undefined").should.equal -1
|
||||||
|
|
||||||
|
describe "projectInvite", ->
|
||||||
|
beforeEach ->
|
||||||
|
@opts =
|
||||||
|
to:"bob@bob.com"
|
||||||
|
first_name:"bob"
|
||||||
|
owner:
|
||||||
|
email:"sally@hally.com"
|
||||||
|
inviteUrl: "http://example.com/invite"
|
||||||
|
project:
|
||||||
|
url:"http://www.project.com"
|
||||||
|
name:"standard project"
|
||||||
|
@email = @EmailBuilder.buildEmail("projectInvite", @opts)
|
||||||
|
|
||||||
|
it 'should have html and text properties', ->
|
||||||
|
expect(@email.html?).to.equal true
|
||||||
|
expect(@email.text?).to.equal true
|
||||||
|
|
||||||
it "should not have undefined in it", ->
|
it "should not have undefined in it", ->
|
||||||
@email.html.indexOf("undefined").should.equal -1
|
@email.html.indexOf("undefined").should.equal -1
|
||||||
@email.subject.indexOf("undefined").should.equal -1
|
@email.subject.indexOf("undefined").should.equal -1
|
||||||
|
|
|
@ -74,3 +74,19 @@ describe "EmailHandler", ->
|
||||||
@EmailHandler.sendEmail "welcome", opts, =>
|
@EmailHandler.sendEmail "welcome", opts, =>
|
||||||
@EmailSender.sendEmail.called.should.equal true
|
@EmailSender.sendEmail.called.should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
describe 'with plain-text email content', () ->
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
@text = "hello there"
|
||||||
|
|
||||||
|
it 'should pass along the text field', (done) ->
|
||||||
|
@EmailBuilder.buildEmail.returns({html: @html, text: @text})
|
||||||
|
@EmailSender.sendEmail.callsArgWith(1)
|
||||||
|
opts =
|
||||||
|
to: "bob@bob.com"
|
||||||
|
@EmailHandler.sendEmail "welcome", opts, =>
|
||||||
|
args = @EmailSender.sendEmail.args[0][0]
|
||||||
|
args.html.should.equal @html
|
||||||
|
args.text.should.equal @text
|
||||||
|
done()
|
||||||
|
|
|
@ -83,3 +83,19 @@ describe "EmailSender", ->
|
||||||
args = @sesClient.sendMail.args[0][0]
|
args = @sesClient.sendMail.args[0][0]
|
||||||
args.replyTo.should.equal @opts.replyTo
|
args.replyTo.should.equal @opts.replyTo
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
describe 'with plain-text email content', () ->
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
@opts.text = "hello there"
|
||||||
|
|
||||||
|
it "should set the text property on the email to send", (done)->
|
||||||
|
@sesClient.sendMail.callsArgWith(1)
|
||||||
|
|
||||||
|
@sender.sendEmail @opts, =>
|
||||||
|
args = @sesClient.sendMail.args[0][0]
|
||||||
|
args.html.should.equal @opts.html
|
||||||
|
args.text.should.equal @opts.text
|
||||||
|
args.to.should.equal @opts.to
|
||||||
|
args.subject.should.equal @opts.subject
|
||||||
|
done()
|
||||||
|
|
Loading…
Reference in a new issue