mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	added default payload to emails, and adding nodebb logo for email header
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								public/images/emails/nodebb.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/images/emails/nodebb.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 6.1 KiB  | 
@@ -25,10 +25,17 @@ var fallbackTransport;
 | 
			
		||||
 | 
			
		||||
var Emailer = module.exports;
 | 
			
		||||
 | 
			
		||||
Emailer._defaultPayload = {};
 | 
			
		||||
 | 
			
		||||
Emailer.registerApp = function (expressApp) {
 | 
			
		||||
	app = expressApp;
 | 
			
		||||
 | 
			
		||||
	Emailer._defaultPayload = {
 | 
			
		||||
		url: nconf.get('url'),
 | 
			
		||||
		site_title: meta.config.title || 'NodeBB',
 | 
			
		||||
		'brand:logo': nconf.get('url') + meta.config['brand:logo'],
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	// Enable Gmail transport if enabled in ACP
 | 
			
		||||
	if (parseInt(meta.config['email:GmailTransport:enabled'], 10) === 1) {
 | 
			
		||||
		transports.gmail = nodemailer.createTransport(smtpTransport({
 | 
			
		||||
@@ -55,6 +62,9 @@ Emailer.send = function (template, uid, params, callback) {
 | 
			
		||||
		return callback();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Combined passed-in payload with default values
 | 
			
		||||
	params = Object.assign({}, Emailer._defaultPayload, params);
 | 
			
		||||
 | 
			
		||||
	async.waterfall([
 | 
			
		||||
		function (next) {
 | 
			
		||||
			async.parallel({
 | 
			
		||||
 
 | 
			
		||||
@@ -124,8 +124,6 @@ module.exports = function (Messaging) {
 | 
			
		||||
						subject: '[[email:notif.chat.subject, ' + messageObj.fromUser.username + ']]',
 | 
			
		||||
						summary: '[[notifications:new_message_from, ' + messageObj.fromUser.username + ']]',
 | 
			
		||||
						message: messageObj,
 | 
			
		||||
						site_title: meta.config.title || 'NodeBB',
 | 
			
		||||
						url: nconf.get('url'),
 | 
			
		||||
						roomId: messageObj.roomId,
 | 
			
		||||
						username: userData.username,
 | 
			
		||||
						userslug: userData.userslug,
 | 
			
		||||
 
 | 
			
		||||
@@ -228,8 +228,6 @@ SocketAdmin.email.test = function (socket, data, callback) {
 | 
			
		||||
	var site_title = meta.config.title || 'NodeBB';
 | 
			
		||||
	var payload = {
 | 
			
		||||
		subject: '[' + site_title + '] Test Email',
 | 
			
		||||
		site_title: site_title,
 | 
			
		||||
		url: nconf.get('url'),
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	switch (data.template) {
 | 
			
		||||
 
 | 
			
		||||
@@ -128,7 +128,6 @@ SocketUser.reset.commit = function (socket, data, callback) {
 | 
			
		||||
			emailer.send('reset_notify', uid, {
 | 
			
		||||
				username: username,
 | 
			
		||||
				date: parsedDate,
 | 
			
		||||
				site_title: meta.config.title || 'NodeBB',
 | 
			
		||||
				subject: '[[email:reset.notify.subject]]',
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -107,7 +107,6 @@ module.exports = function (SocketUser) {
 | 
			
		||||
				var siteTitle = meta.config.title || 'NodeBB';
 | 
			
		||||
				var data = {
 | 
			
		||||
					subject: '[[email:banned.subject, ' + siteTitle + ']]',
 | 
			
		||||
					site_title: siteTitle,
 | 
			
		||||
					username: username,
 | 
			
		||||
					until: until ? utils.toISOString(until) : false,
 | 
			
		||||
					reason: reason,
 | 
			
		||||
 
 | 
			
		||||
@@ -259,7 +259,6 @@ module.exports = function (Topics) {
 | 
			
		||||
								subject: '[' + (meta.config.title || 'NodeBB') + '] ' + title,
 | 
			
		||||
								intro: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + titleEscaped + ']]',
 | 
			
		||||
								postBody: postData.content.replace(/"\/\//g, '"https://'),
 | 
			
		||||
								site_title: meta.config.title || 'NodeBB',
 | 
			
		||||
								username: data.userData.username,
 | 
			
		||||
								userslug: data.userData.userslug,
 | 
			
		||||
								url: nconf.get('url') + '/topic/' + postData.topic.tid,
 | 
			
		||||
 
 | 
			
		||||
@@ -89,7 +89,6 @@ module.exports = function (User) {
 | 
			
		||||
				var title = meta.config.title || meta.config.browserTitle || 'NodeBB';
 | 
			
		||||
				translator.translate('[[email:welcome-to, ' + title + ']]', meta.config.defaultLang, function (subject) {
 | 
			
		||||
					var data = {
 | 
			
		||||
						site_title: title,
 | 
			
		||||
						username: username,
 | 
			
		||||
						subject: subject,
 | 
			
		||||
						template: 'registration_accepted',
 | 
			
		||||
 
 | 
			
		||||
@@ -136,8 +136,6 @@ Digest.send = function (data, callback) {
 | 
			
		||||
							subject: '[' + meta.config.title + '] [[email:digest.subject, ' + (now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()) + ']]',
 | 
			
		||||
							username: userObj.username,
 | 
			
		||||
							userslug: userObj.userslug,
 | 
			
		||||
							url: nconf.get('url'),
 | 
			
		||||
							site_title: meta.config.title || meta.config.browserTitle || 'NodeBB',
 | 
			
		||||
							notifications: notifications,
 | 
			
		||||
							recent: data.topics,
 | 
			
		||||
							interval: data.interval,
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,6 @@ UserEmail.sendValidationEmail = function (uid, options, callback) {
 | 
			
		||||
			var title = meta.config.title || meta.config.browserTitle || 'NodeBB';
 | 
			
		||||
			translator.translate('[[email:welcome-to, ' + title + ']]', meta.config.defaultLang, function (subject) {
 | 
			
		||||
				var data = {
 | 
			
		||||
					site_title: title,
 | 
			
		||||
					username: username,
 | 
			
		||||
					confirm_link: confirm_link,
 | 
			
		||||
					confirm_code: confirm_code,
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,6 @@ UserReset.send = function (email, callback) {
 | 
			
		||||
		function (subject, code, next) {
 | 
			
		||||
			var reset_link = nconf.get('url') + '/reset/' + code;
 | 
			
		||||
			emailer.send('reset', uid, {
 | 
			
		||||
				site_title: (meta.config.title || 'NodeBB'),
 | 
			
		||||
				reset_link: reset_link,
 | 
			
		||||
				subject: subject,
 | 
			
		||||
				template: 'reset',
 | 
			
		||||
 
 | 
			
		||||
@@ -173,12 +173,22 @@
 | 
			
		||||
			<td>
 | 
			
		||||
			<![endif]-->
 | 
			
		||||
 | 
			
		||||
			<!-- Email Header : BEGIN -->
 | 
			
		||||
			<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 600px;">
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td style="padding: 20px 0; text-align: center">
 | 
			
		||||
						<img src="http://juliantest.nodebb.com/assets/images/emails/nodebb.png" height="100" width="245" alt="alt_text" border="0" style="height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
			</table>
 | 
			
		||||
			<!-- Email Header : END -->
 | 
			
		||||
 | 
			
		||||
			<!-- Email Body : BEGIN -->
 | 
			
		||||
			<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 600px;">
 | 
			
		||||
 | 
			
		||||
				<!-- Hero Image, Flush : BEGIN -->
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td bgcolor="#ffffff" style="text-align: center; background-image: url(http://juliantest.nodebb.com/assets/images/emails/triangularbackground.png); background-size: cover; background-repeat: no-repeat;">
 | 
			
		||||
					<td bgcolor="#efeff0" style="text-align: center; background-image: url(http://juliantest.nodebb.com/assets/images/emails/triangularbackground.png); background-size: cover; background-repeat: no-repeat;">
 | 
			
		||||
						<img src="http://juliantest.nodebb.com/assets/images/emails/emailconfirm.png" width="600" height="" alt="alt_text" border="0" align="center" style="width: 50%; max-width: 600px; height: auto; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;" class="g-img">
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
@@ -186,7 +196,7 @@
 | 
			
		||||
 | 
			
		||||
				<!-- 1 Column Text + Button : BEGIN -->
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td bgcolor="#ffffff">
 | 
			
		||||
					<td bgcolor="#efeff0">
 | 
			
		||||
						<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
 | 
			
		||||
							<tr>
 | 
			
		||||
								<td style="padding: 40px; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user