@ -12,7 +12,53 @@ Accounts.emailTemplates.siteName = RocketChat.settings.get('Site_Name');
Accounts . emailTemplates . from = ` ${ RocketChat . settings . get ( 'Site_Name' ) } < ${ RocketChat . settings . get ( 'From_Email' ) } > ` ;
Accounts . emailTemplates . notifyAdmin = { } ;
Accounts . emailTemplates . userToActivate = {
subject ( ) {
const subject = TAPi18n . _ _ ( 'Accounts_Admin_Email_Approval_Needed_Subject_Default' ) ;
const siteName = RocketChat . settings . get ( 'Site_Name' ) ;
return ` [ ${ siteName } ] ${ subject } ` ;
} ,
html ( options = { } ) {
const header = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Header' ) || '' ) ;
const footer = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Footer' ) || '' ) ;
const email = options . reason ? 'Accounts_Admin_Email_Approval_Needed_With_Reason_Default' : 'Accounts_Admin_Email_Approval_Needed_Default' ;
const html = RocketChat . placeholders . replace ( TAPi18n . _ _ ( email ) , {
name : options . name ,
email : options . email ,
reason : options . reason
} ) ;
return header + html + footer ;
}
} ;
Accounts . emailTemplates . userActivated = {
subject ( { active , username } ) {
const action = active ? ( username ? 'Activated' : 'Approved' ) : 'Deactivated' ;
const subject = ` Accounts_Email_ ${ action } _Subject ` ;
const siteName = RocketChat . settings . get ( 'Site_Name' ) ;
return ` [ ${ siteName } ] ${ TAPi18n . _ _ ( subject ) } ` ;
} ,
html ( { active , name , username } ) {
const header = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Header' ) || '' ) ;
const footer = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Footer' ) || '' ) ;
const action = active ? ( username ? 'Activated' : 'Approved' ) : 'Deactivated' ;
const html = RocketChat . placeholders . replace ( TAPi18n . _ _ ( ` Accounts_Email_ ${ action } ` ) , {
name
} ) ;
return header + html + footer ;
}
} ;
const verifyEmailHtml = Accounts . emailTemplates . verifyEmail . text ;
@ -61,28 +107,6 @@ Accounts.emailTemplates.enrollAccount.html = function(user = {}/*, url*/) {
return header + html + footer ;
} ;
Accounts . emailTemplates . notifyAdmin . subject = function ( ) {
const subject = TAPi18n . _ _ ( 'Accounts_Admin_Email_Approval_Needed_Subject_Default' ) ;
const siteName = RocketChat . settings . get ( 'Site_Name' ) ;
return ` [ ${ siteName } ] ${ subject } ` ;
} ;
Accounts . emailTemplates . notifyAdmin . html = function ( options = { } ) {
const header = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Header' ) || '' ) ;
const footer = RocketChat . placeholders . replace ( RocketChat . settings . get ( 'Email_Footer' ) || '' ) ;
const email = options . reason ? 'Accounts_Admin_Email_Approval_Needed_With_Reason_Default' : 'Accounts_Admin_Email_Approval_Needed_Default' ;
const html = RocketChat . placeholders . replace ( TAPi18n . _ _ ( email ) , {
name : options . name ,
email : options . email ,
reason : options . reason
} ) ;
return header + html + footer ;
} ;
Accounts . onCreateUser ( function ( options , user = { } ) {
RocketChat . callbacks . run ( 'beforeCreateUser' , options , user ) ;
@ -123,8 +147,8 @@ Accounts.onCreateUser(function(options, user = {}) {
RocketChat . models . Roles . findUsersInRole ( 'admin' ) . forEach ( adminUser => {
if ( Array . isArray ( adminUser . emails ) ) {
adminUser . emails . forEach ( address => {
destinations . push ( ` ${ adminUser . name } < ${ address } > ` ) ;
adminUser . emails . forEach ( email => {
destinations . push ( ` ${ adminUser . name } < ${ email . address } > ` ) ;
} ) ;
}
} ) ;
@ -132,8 +156,8 @@ Accounts.onCreateUser(function(options, user = {}) {
const email = {
to : destinations ,
from : RocketChat . settings . get ( 'From_Email' ) ,
subject : Accounts . emailTemplates . notifyAdmin . subject ( ) ,
html : Accounts . emailTemplates . notifyAdmin . html ( options )
subject : Accounts . emailTemplates . userToActivate . subject ( ) ,
html : Accounts . emailTemplates . userToActivate . html ( options )
} ;
Meteor . defer ( ( ) => Email . send ( email ) ) ;