Skip to content

Commit

Permalink
Changes to Email settings (#3007)
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloschmidt authored and engelgabriel committed Apr 22, 2016
1 parent 184bdbd commit afb890f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
6 changes: 5 additions & 1 deletion packages/rocketchat-lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"Accounts_EmailVerification" : "Email Verification",
"Accounts_EmailVerification_Description" : "Make sure you have correct SMTP settings to use this feature",
"Accounts_Enrollment_Email" : "Enrollment Email",
"Accounts_Enrollment_Email_Description" : "You may use [name], [fname], [lname] for the user's full name, first name or last name, respectively.<br />You may use [email] for the user's email.",
"Accounts_Enrollment_Email_Description" : "You may use the following placeholders: <br /><ul><li>[name], [fname], [lname] for the user's full name, first name or last name, respectively.</li><li>[email] for the user's email.</li><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>",
"Accounts_Iframe_api_method" : "Api Method",
"Accounts_Iframe_api_url" : "API URL",
"Accounts_iframe_enabled" : "Enabled",
Expand Down Expand Up @@ -413,6 +413,7 @@
"Highlights_How_To" : "To be notified when someone mentions a word or phrase, add it here. You can separate words or phrases with commas. Highlight Words are not case sensitive.",
"Highlights_List" : "Highlight words",
"History" : "History",
"Host" : "Host",
"hours" : "hours",
"How_friendly_was_the_chat_agent" : "How friendly was the chat agent?",
"How_knowledgeable_was_the_chat_agent" : "How knowledgeable was the chat agent?",
Expand Down Expand Up @@ -464,6 +465,8 @@
"invisible" : "invisible",
"Invisible" : "Invisible",
"Invitation_HTML" : "Invitation HTML",
"Invitation_HTML_Description" : "You may use the following placeholders: <br /><ul><li>[email] for the recipient email.</li><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>",
"Invitation_HTML_Template" : "<h2>You have been invited to <h1>[Site_Name]</h1></h2><p>Go to [Site_URL] and try the best open source chat solution available today!</p>",
"Invitation_Subject" : "Invitation Subject",
"Invite_user_to_join_channel" : "Invite one user to join this channel",
"Invite_Users" : "Invite Users",
Expand Down Expand Up @@ -750,6 +753,7 @@
"Please_wait_while_OTR_is_being_established" : "Please wait while OTR is being established",
"Please_wait_while_your_account_is_being_deleted" : "Please wait while your account is being deleted...",
"Please_wait_while_your_profile_is_being_saved" : "Please wait while your profile is being saved...",
"Port" : "Port",
"Post_as" : "Post as",
"Post_to_Channel" : "Post to Channel",
"Post_to_s_as_s" : "Post to <strong>%s</strong> as <strong>%s</strong>",
Expand Down
26 changes: 15 additions & 11 deletions packages/rocketchat-lib/server/startup/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,26 @@ RocketChat.settings.addGroup 'General', ->
@add 'Desktop_Notifications_Duration', 0, { type: 'int', public: true, i18nDescription: 'Desktop_Notification_Durations_Description' }


RocketChat.settings.addGroup 'SMTP', ->
@add 'SMTP_Host', '', { type: 'string', env: true }
@add 'SMTP_Port', '', { type: 'string', env: true }
@add 'SMTP_Username', '', { type: 'string', env: true }
@add 'SMTP_Password', '', { type: 'password', env: true }
@add 'From_Email', '', { type: 'string', placeholder: 'email@domain' }
@add 'SMTP_Test_Button', 'sendSMTPTestEmail', { type: 'action', actionText: 'Send_a_test_mail_to_my_user' }
RocketChat.settings.addGroup 'Email', ->
@section 'SMTP', ->
@add 'SMTP_Host', '', { type: 'string', env: true, i18nLabel: 'Host' }
@add 'SMTP_Port', '', { type: 'string', env: true, i18nLabel: 'Port' }
@add 'SMTP_Username', '', { type: 'string', env: true, i18nLabel: 'Username' }
@add 'SMTP_Password', '', { type: 'password', env: true, i18nLabel: 'Password' }
@add 'From_Email', '', { type: 'string', placeholder: 'email@domain' }
@add 'SMTP_Test_Button', 'sendSMTPTestEmail', { type: 'action', actionText: 'Send_a_test_mail_to_my_user' }

@section 'Invitation', ->
@add 'Invitation_Subject', 'You have been invited to Rocket.Chat', { type: 'string' }
@add 'Invitation_HTML', '<h2>You have been invited to <h1>Rocket.Chat</h1></h2><p>Go to ' + __meteor_runtime_config__?.ROOT_URL + ' and try the best open source chat solution available today!</p>', { type: 'string', multiline: true }
@add 'Accounts_Enrollment_Email', '', { type: 'string', multiline: true }
@add 'Invitation_Subject', 'You have been invited to Rocket.Chat', { type: 'string', i18nLabel: 'Subject' }
@add 'Invitation_HTML', '', { type: 'code', code: 'text/html', multiline: true, i18nLabel: 'Body', i18nDescription: 'Invitation_HTML_Description' }

@section 'Registration', ->
@add 'Accounts_Enrollment_Email_Subject', '', { type: 'string', i18nLabel: 'Subject' }
@add 'Accounts_Enrollment_Email', '', { type: 'code', code: 'text/html', multiline: true, i18nLabel: 'Body', i18nDescription: 'Accounts_Enrollment_Email_Description' }

@section 'Registration via Admin', ->
@add 'Accounts_UserAddedEmail', '', { type: 'string', multiline: true, i18nLabel: 'Email', i18nDescription: 'Accounts_UserAddedEmail_Description' }
@add 'Accounts_UserAddedEmailSubject', '', { type: 'string', i18nLabel: "Subject" }
@add 'Accounts_UserAddedEmail', '', { type: 'code', code: 'text/html', multiline: true, i18nLabel: 'Body', i18nDescription: 'Accounts_UserAddedEmail_Description' }


RocketChat.settings.addGroup 'Message', ->
Expand Down
8 changes: 6 additions & 2 deletions server/lib/accounts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ Accounts.emailTemplates.resetPassword.text = (user, url) ->
url = url.replace /\/#\//, '/'
resetPasswordText user, url

if RocketChat.settings.get 'Accounts_Enrollment_Email_Subject'
Accounts.emailTemplates.enrollAccount.subject = (user) ->
return RocketChat.settings.get 'Accounts_Enrollment_Email_Subject'

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 ''

text = text.replace /\[Site_Name\]/g, RocketChat.settings.get("Site_Name") or ''
text = text.replace /\[Site_URL\]/g, RocketChat.settings.get("Site_Url") or ''
return text

Accounts.onCreateUser (options, user) ->
Expand Down

0 comments on commit afb890f

Please sign in to comment.