From 751a116921ad4b3900108ee3eacd99e723fc1169 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 27 Oct 2016 14:41:13 +0100 Subject: [PATCH 1/2] add plainTextTemplate to all emails --- .../coffee/Features/Email/EmailBuilder.coffee | 60 +++++++++++++++++++ .../coffee/Email/EmailBuilderTests.coffee | 4 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 5ceece048e..6a0cd6aab4 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -7,10 +7,18 @@ settings = require("settings-sharelatex") templates = {} + templates.registered = subject: _.template "Activate your #{settings.appName} Account" layout: PersonalEmailLayout type: "notification" + plainTextTemplate: _.template """ +Congratulations, you've just had an account created for you on #{settings.appName} with the email address "<%= to %>". + +Click here to set your password and log in: <%= setNewPasswordUrl %> + +If you have any questions or problems, please contact #{settings.adminEmail} +""" compiledTemplate: _.template """

Congratulations, you've just had an account created for you on #{settings.appName} with the email address "<%= to %>".

@@ -19,10 +27,24 @@ templates.registered =

If you have any questions or problems, please contact #{settings.adminEmail}.

""" + templates.canceledSubscription = subject: _.template "ShareLaTeX thoughts" layout: PersonalEmailLayout type:"lifecycle" + plainTextTemplate: _.template """ +Hi <%= first_name %>, + +I'm sorry to see you cancelled your ShareLaTeX premium account. Would you mind giving me some advice on what the site is lacking at the moment via this survey?: + +https://sharelatex.typeform.com/to/f5lBiZ + +Thank you in advance. + +Henry + +ShareLaTeX Co-founder +""" compiledTemplate: _.template '''

Hi <%= first_name %>,

@@ -36,10 +58,26 @@ ShareLaTeX Co-founder

''' + templates.passwordResetRequested = subject: _.template "Password Reset - #{settings.appName}" layout: NotificationEmailLayout type:"notification" + plainTextTemplate: _.template """ +Password Reset + +We got a request to reset your #{settings.appName} password. + +Click this link to reset your password: <%= setNewPasswordUrl %> + +If you ignore this message, your password won't be changed. + +If you didn't request a password reset, let us know. + +Thank you + +#{settings.appName} - <%= siteUrl %> +""" compiledTemplate: _.template """

Password Reset

@@ -66,10 +104,20 @@ If you didn't request a password reset, let us know.

#{settings.appName}

""" + templates.projectSharedWithYou = subject: _.template "<%= owner.email %> wants to share <%= project.name %> with you" layout: NotificationEmailLayout type:"notification" + plainTextTemplate: _.template """ +Hi, <%= owner.email %> wants to share '<%= project.name %>' (<%= project.url %>) with you. + +Click this link to view the project: <%= project.url %> + +Thank you + +#{settings.appName} - <%= siteUrl %> +""" compiledTemplate: _.template """

Hi, <%= owner.email %> wants to share '<%= project.name %>' with you

@@ -87,6 +135,7 @@ templates.projectSharedWithYou =

#{settings.appName}

""" + templates.projectInvite = subject: _.template "<%= project.name %> - shared by <%= owner.email %>" layout: NotificationEmailLayout @@ -113,10 +162,20 @@ Thank you

#{settings.appName}

""" + templates.completeJoinGroupAccount = subject: _.template "Verify Email to join <%= group_name %> group" layout: NotificationEmailLayout type:"notification" + plainTextTemplate: _.template """ +Hi, please verify your email to join the <%= group_name %> and get your free premium account + +Click this link to verify now: <%= completeJoinUrl %> + +Thank You + +#{settings.appName} - <%= siteUrl %> +""" compiledTemplate: _.template """

Hi, please verify your email to join the <%= group_name %> and get your free premium account

@@ -134,6 +193,7 @@ templates.completeJoinGroupAccount =

#{settings.appName}

""" + module.exports = templates: templates diff --git a/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee b/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee index ff51507636..18a3096f12 100644 --- a/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee +++ b/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee @@ -34,9 +34,9 @@ describe "EmailBuilder", -> @email.html.indexOf(@opts.owner.email).should.not.equal -1 @email.subject.indexOf(@opts.owner.email).should.not.equal -1 - it 'should not have text component', -> + it 'should have html and text properties', -> expect(@email.html?).to.equal true - expect(@email.text?).to.equal false + expect(@email.text?).to.equal true it "should not have undefined in it", -> @email.html.indexOf("undefined").should.equal -1 From 4c092e7ff124708f95d94a3c41a797f7ddb33b90 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 28 Oct 2016 10:37:10 +0100 Subject: [PATCH 2/2] Remove deprecated "projectSharedWithYou" email. --- .../CollaboratorsEmailHandler.coffee | 21 ------------- .../coffee/Features/Email/EmailBuilder.coffee | 31 ------------------- .../coffee/Email/EmailBuilderTests.coffee | 24 -------------- 3 files changed, 76 deletions(-) diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsEmailHandler.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsEmailHandler.coffee index f669d85de4..bc7eb90c3f 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsEmailHandler.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsEmailHandler.coffee @@ -11,27 +11,6 @@ module.exports = CollaboratorsEmailHandler = "user_first_name=#{encodeURIComponent(project.owner_ref.first_name)}" ].join("&") - notifyUserOfProjectShare: (project_id, email, callback)-> - Project - .findOne(_id: project_id ) - .select("name owner_ref") - .populate('owner_ref') - .exec (err, project)-> - emailOptions = - to: email - replyTo: project.owner_ref.email - project: - name: project.name - url: "#{Settings.siteUrl}/project/#{project._id}?" + [ - "project_name=#{encodeURIComponent(project.name)}" - "user_first_name=#{encodeURIComponent(project.owner_ref.first_name)}" - "new_email=#{encodeURIComponent(email)}" - "r=#{project.owner_ref.referal_id}" # Referal - "rs=ci" # referral source = collaborator invite - ].join("&") - owner: project.owner_ref - EmailHandler.sendEmail "projectSharedWithYou", emailOptions, callback - notifyUserOfProjectInvite: (project_id, email, invite, callback)-> Project .findOne(_id: project_id ) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 6a0cd6aab4..70d11e219b 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -105,37 +105,6 @@ If you didn't request a password reset, let us know. """ -templates.projectSharedWithYou = - subject: _.template "<%= owner.email %> wants to share <%= project.name %> with you" - layout: NotificationEmailLayout - type:"notification" - plainTextTemplate: _.template """ -Hi, <%= owner.email %> wants to share '<%= project.name %>' (<%= project.url %>) with you. - -Click this link to view the project: <%= project.url %> - -Thank you - -#{settings.appName} - <%= siteUrl %> -""" - compiledTemplate: _.template """ -

Hi, <%= owner.email %> wants to share '<%= project.name %>' with you

-
- -
-

Thank you

-

#{settings.appName}

-""" - - templates.projectInvite = subject: _.template "<%= project.name %> - shared by <%= owner.email %>" layout: NotificationEmailLayout diff --git a/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee b/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee index 18a3096f12..4ee0e0ed05 100644 --- a/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee +++ b/services/web/test/UnitTests/coffee/Email/EmailBuilderTests.coffee @@ -18,30 +18,6 @@ describe "EmailBuilder", -> "settings-sharelatex":@settings "logger-sharelatex": log:-> - describe "projectSharedWithYou", -> - beforeEach -> - @opts = - to:"bob@bob.com" - first_name:"bob" - owner: - email:"sally@hally.com" - project: - url:"http://www.project.com" - name:"standard project" - @email = @EmailBuilder.buildEmail("projectSharedWithYou", @opts) - - it "should insert the owner email into the template", -> - @email.html.indexOf(@opts.owner.email).should.not.equal -1 - @email.subject.indexOf(@opts.owner.email).should.not.equal -1 - - 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", -> - @email.html.indexOf("undefined").should.equal -1 - @email.subject.indexOf("undefined").should.equal -1 - describe "projectInvite", -> beforeEach -> @opts =