From 7fc68cd913de08cd340c82d3d00f86e19406ed9d Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt Date: Wed, 11 Nov 2015 17:29:27 -0200 Subject: [PATCH 1/2] Add enrollment email --- client/views/admin/admin.html | 2 +- i18n/en.i18n.json | 4 +++- .../rocketchat-lib/settings/server/startup.coffee | 1 + server/lib/accounts.coffee | 11 +++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/views/admin/admin.html b/client/views/admin/admin.html index 36d96f01d31..bb87193a709 100644 --- a/client/views/admin/admin.html +++ b/client/views/admin/admin.html @@ -55,7 +55,7 @@ {{/if}} {{#if description}}
- {{description}} + {{{description}}}
{{/if}} diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 5abc995c31a..301e266eb31 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -45,6 +45,8 @@ "Accounts_OAuth_Custom_Button_Label_Color" : "Button Text Color", "Accounts_OAuth_Custom_Button_Color" : "Button Color", "Accounts_RequireNameForSignUp" : "Require name for signup", + "Accounts_Enrollment_Email": "Enrollment E-mail", + "Accounts_Enrollment_Email_Description": "You may use [name], [fname], [lname] for the user's full name, first name or last name, respectively.
You may use [email] for the user's e-mail.", "Activate" : "Activate", "Add_custom_oauth" : "Add custom oauth", "Add_Members" : "Add Members", @@ -453,4 +455,4 @@ "You_will_not_be_able_to_recover" : "You will not be able to recover this message!", "Your_entry_has_been_deleted" : "Your entry has been deleted.", "Your_Open_Source_solution" : "Your own Open Source chat solution" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/settings/server/startup.coffee b/packages/rocketchat-lib/settings/server/startup.coffee index 7821c68fefe..f579dc06b94 100644 --- a/packages/rocketchat-lib/settings/server/startup.coffee +++ b/packages/rocketchat-lib/settings/server/startup.coffee @@ -68,6 +68,7 @@ RocketChat.settings.add 'From_Email', 'no-reply@rocket.chat', { type: 'string', RocketChat.settings.add 'Invitation_Subject', 'You have been invited to Rocket.Chat', { type: 'string', group: 'SMTP', section: 'Invitation' } RocketChat.settings.add 'Invitation_HTML', '

You have been invited to

Rocket.Chat

Go to https://demo.rocket.chat and try the best open source chat solution available today!

', { type: 'string', multiline: true, group: 'SMTP', section: 'Invitation' } +RocketChat.settings.add 'Accounts_Enrollment_Email', '', { type: 'string', multiline: true, group: 'SMTP', section: 'Invitation' } RocketChat.settings.addGroup 'Message' RocketChat.settings.add 'Message_AllowEditing', true, { type: 'boolean', group: 'Message', public: true } diff --git a/server/lib/accounts.coffee b/server/lib/accounts.coffee index 23047777530..eb0878f6cfc 100644 --- a/server/lib/accounts.coffee +++ b/server/lib/accounts.coffee @@ -27,6 +27,17 @@ Accounts.emailTemplates.resetPassword.text = (user, url) -> url = url.replace Meteor.absoluteUrl(), Meteor.absoluteUrl() + 'login/' verifyEmailText user, url +if RocketChat.settings.get 'Accounts_Enrollment_Email' + Accounts.emailTemplates.enrollAccount.text = (user, url) -> + text = RocketChat.settings.get 'Accounts_Enrollment_Email' + + text = text.replace /\[name\]/g, user.name or '' + text = text.replace /\[fname\]/g, _.strLeft(user.name, ' ') or '' + text = text.replace /\[lname\]/g, _.strRightBack(user.name, ' ') or '' + text = text.replace /\[email\]/g, user.emails?[0]?.address or '' + + return text + Accounts.onCreateUser (options, user) -> # console.log 'onCreateUser ->',JSON.stringify arguments, null, ' ' # console.log 'options ->',JSON.stringify options, null, ' ' From 2b8524f9c71cd42a78b92787fdb8ea58e7ca2b70 Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt Date: Thu, 12 Nov 2015 14:31:28 -0200 Subject: [PATCH 2/2] Send e-mail on first username set --- packages/rocketchat-lib/server/functions/setUsername.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/rocketchat-lib/server/functions/setUsername.coffee b/packages/rocketchat-lib/server/functions/setUsername.coffee index 9497f705f71..2e4d5982937 100644 --- a/packages/rocketchat-lib/server/functions/setUsername.coffee +++ b/packages/rocketchat-lib/server/functions/setUsername.coffee @@ -16,6 +16,10 @@ RocketChat.setUsername = (user, username) -> previousUsername = user.username + # If first time setting username, send Enrollment Email + if not previousUsername and RocketChat.settings.get 'Accounts_Enrollment_Email' + Accounts.sendEnrollmentEmail(user._id) + # Username is available; if coming from old username, update all references if previousUsername RocketChat.models.Messages.updateAllUsernamesByUserId user._id, username