some fixes
This commit is contained in:
		
							parent
							
								
									44b2ba3da7
								
							
						
					
					
						commit
						1e0c0bd586
					
				
					 2 changed files with 9 additions and 6 deletions
				
			
		|  | @ -96,11 +96,12 @@ exports.setAuthorEmailRegistered = function(email, authorId, padId){ | |||
|       timestamp: timestamp | ||||
|   }; | ||||
|   console.debug("registered", registered, " to ", padId); | ||||
| 
 | ||||
|   console.warn("WTF"); | ||||
|   // Here we have to basically hack a new value into the database, this isn't clean or polite.
 | ||||
|   db.get("emailSubscription:" + padId, function(err, value){ // get the current value
 | ||||
|     if(!value){value = {};} // if an emailSubscription doesnt exist yet for this padId don't panic
 | ||||
|     value[email] = registered; // add the registered values to the object
 | ||||
|     console.warn("written to database"); | ||||
|     db.set("emailSubscription:" + padId, value); // stick it in the database
 | ||||
|   }); | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										12
									
								
								update.js
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								update.js
									
										
									
									
									
								
							|  | @ -13,7 +13,7 @@ var staleTime = 30000; // How stale(milliseconds) does a pad need to be before n | |||
| var timers = {}; | ||||
| var fromName = "Etherpad"; | ||||
| var fromEmail = "pad@etherpad.org"; | ||||
| var urlToPads = "http://beta.etherpad.org/p/"; | ||||
| var urlToPads = "http://beta.etherpad.org/p/"; // The URL to your pads note the trailing /
 | ||||
| 
 | ||||
| var server  = email.server.connect({ | ||||
|    host:    "127.0.0.1",  | ||||
|  | @ -39,12 +39,14 @@ exports.padUpdate = function (hook_name, _pad) { | |||
| }; | ||||
| 
 | ||||
| exports.notifyBegin = function(padId){ | ||||
|   console.warn("Getting "+padId); | ||||
|   db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
 | ||||
|     console.warn(recipients); | ||||
|     async.forEach(Object.keys(recipients), function(recipient, cb){ | ||||
|       console.debug("Emailing "+recipient +" about a new begin update"); | ||||
|       console.warn("Emailing "+recipient +" about a new begin update"); | ||||
| 
 | ||||
|       server.send({ | ||||
|         text:    "Your pad at "+urlToPads+"/p/"+padId +" is being edited, we're just emailing you let you know :)",  | ||||
|         text:    "Your pad at "+urlToPads+padId +" is being edited, we're just emailing you let you know :)",  | ||||
|         from:    fromName+ "<"+fromEmail+">",  | ||||
|         to:      recipient, | ||||
|         subject: "Someone begin editing "+padId | ||||
|  | @ -67,10 +69,10 @@ exports.notifyEnd = function(padId){ | |||
|       console.debug("Emailing "+recipient +" about a new begin update"); | ||||
| 
 | ||||
|       server.send({ | ||||
|         text:    "Your pad at "+urlToPads+"/p/"+padId +" has finished being edited, we're just emailing you let you know :)  The changes look like this:" + changesToPad, | ||||
|         text:    "Your pad at "+urlToPads+padId +" has finished being edited, we're just emailing you let you know :)  The changes look like this:" + changesToPad, | ||||
|         from:    fromName+ "<"+fromEmail+">", | ||||
|         to:      recipient, | ||||
|         subject: "Someone begin editing "+padId | ||||
|         subject: "Someone finished editing "+padId | ||||
|       }, function(err, message) { console.log(err || message); }); | ||||
| 
 | ||||
|       cb(); // finish each user
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John McLear
						John McLear