update: Improve email text.
* Make the text less verbose. * Tell the reader how to unsubscribe. * Remove the placeholder for document changes.
This commit is contained in:
		
							parent
							
								
									96410df84c
								
							
						
					
					
						commit
						63403293d0
					
				
					 1 changed files with 12 additions and 5 deletions
				
			
		
							
								
								
									
										17
									
								
								update.js
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								update.js
									
										
									
									
									
								
							|  | @ -4,7 +4,8 @@ | ||||||
|    async = require('../../src/node_modules/async'), |    async = require('../../src/node_modules/async'), | ||||||
|    check = require('validator').check, |    check = require('validator').check, | ||||||
|    email = require('emailjs'), |    email = require('emailjs'), | ||||||
| settings = require('../../src/node/utils/Settings'); | settings = require('../../src/node/utils/Settings'), | ||||||
|  |     util = require('util'); | ||||||
| 
 | 
 | ||||||
| // Settings -- EDIT THESE IN settings.json not here..
 | // Settings -- EDIT THESE IN settings.json not here..
 | ||||||
| var pluginSettings = settings.ep_email_notifications; | var pluginSettings = settings.ep_email_notifications; | ||||||
|  | @ -22,6 +23,8 @@ var timers = {}; | ||||||
| // Connect to the email server -- This might not be the ideal place to connect but it stops us having lots of connections 
 | // Connect to the email server -- This might not be the ideal place to connect but it stops us having lots of connections 
 | ||||||
| var server  = email.server.connect(emailServer); | var server  = email.server.connect(emailServer); | ||||||
| 
 | 
 | ||||||
|  | var emailFooter = "\nYou can unsubscribe from these emails in the pad's Settings window.\n"; | ||||||
|  | 
 | ||||||
| exports.padUpdate = function (hook_name, _pad) { | exports.padUpdate = function (hook_name, _pad) { | ||||||
|   if (areParamsOk == false) return false; |   if (areParamsOk == false) return false; | ||||||
| 
 | 
 | ||||||
|  | @ -41,6 +44,11 @@ exports.padUpdate = function (hook_name, _pad) { | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | padUrl = function(padId, fmt) { | ||||||
|  |   fmt = fmt || "%s"; | ||||||
|  |   return util.format(fmt, urlToPads + padId); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| exports.notifyBegin = function(padId){ | exports.notifyBegin = function(padId){ | ||||||
|   console.warn("Getting pad email stuff for "+padId); |   console.warn("Getting pad email stuff for "+padId); | ||||||
|   db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
 |   db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
 | ||||||
|  | @ -54,7 +62,7 @@ exports.notifyBegin = function(padId){ | ||||||
|             if(!userIsOnPad && onStart){ |             if(!userIsOnPad && onStart){ | ||||||
|               console.debug("Emailing "+recipient +" about a new begin update"); |               console.debug("Emailing "+recipient +" about a new begin update"); | ||||||
|               server.send({ |               server.send({ | ||||||
|                 text:    "Your pad at "+urlToPads+padId +" is being edited, we're just emailing you let you know :)",  |                 text:    "This pad is now being edited:\n" + padUrl(padId, "  <%s>\n") + emailFooter, | ||||||
|                 from:    fromName+ "<"+fromEmail+">",  |                 from:    fromName+ "<"+fromEmail+">",  | ||||||
|                 to:      recipient, |                 to:      recipient, | ||||||
|                 subject: "Someone started editing "+padId |                 subject: "Someone started editing "+padId | ||||||
|  | @ -75,8 +83,7 @@ exports.notifyBegin = function(padId){ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| exports.notifyEnd = function(padId){ | exports.notifyEnd = function(padId){ | ||||||
|   // get the modified contents...
 |   // TODO: get the modified contents to include in the email
 | ||||||
|   var changesToPad = "Functionality does not exist"; |  | ||||||
| 
 | 
 | ||||||
|   db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
 |   db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
 | ||||||
|     if(recipients){ |     if(recipients){ | ||||||
|  | @ -90,7 +97,7 @@ exports.notifyEnd = function(padId){ | ||||||
|             if(!userIsOnPad && onEnd){ |             if(!userIsOnPad && onEnd){ | ||||||
|               console.debug("Emailing "+recipient +" about a pad finished being updated"); |               console.debug("Emailing "+recipient +" about a pad finished being updated"); | ||||||
|               server.send({ |               server.send({ | ||||||
|                 text:    "Your pad at "+urlToPads+padId +" has finished being edited, we're just emailing you let you know :) \n\n  The changes look like this: \n" + changesToPad, |                 text:    "This pad is done being edited:\n" + padUrl(padId, "  <%s>\n") + emailFooter, | ||||||
|                 from:    fromName+ "<"+fromEmail+">", |                 from:    fromName+ "<"+fromEmail+">", | ||||||
|                 to:      recipient, |                 to:      recipient, | ||||||
|                 subject: "Someone finished editing "+padId |                 subject: "Someone finished editing "+padId | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Brett Smith
						Brett Smith