Changed tabs to spaces & removed trailing spaces
This commit is contained in:
		
							parent
							
								
									907ecb9a7b
								
							
						
					
					
						commit
						7d3d2a2920
					
				
					 7 changed files with 64 additions and 63 deletions
				
			
		|  | @ -5,13 +5,6 @@ exports.eejsBlock_scripts = function (hook_name, args, cb) { | |||
|   return cb(); | ||||
| }; | ||||
| 
 | ||||
| /* | ||||
| exports.eejsBlock_embedPopup = function (hook_name, args, cb) { | ||||
|   args.content = args.content + eejs.require("ep_email_notifications/templates/embedFrame.html", {}, module); | ||||
|   return cb(); | ||||
| }; | ||||
| */ | ||||
| 
 | ||||
| exports.eejsBlock_mySettings = function (hook_name, args, cb) { | ||||
|   args.content = args.content + eejs.require('ep_email_notifications/templates/email_notifications_settings.ejs'); | ||||
|   return cb(); | ||||
|  | @ -20,4 +13,3 @@ exports.eejsBlock_mySettings = function (hook_name, args, cb) { | |||
| exports.eejsBlock_styles = function (hook_name, args, cb) { | ||||
|   args.content = args.content + '<link href="../static/plugins/ep_email_notifications/static/css/email_notifications.css" rel="stylesheet">'; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,7 +46,8 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|             } else if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == false){ | ||||
|               // SUbscription
 | ||||
|               var validatesAsEmail = check(context.message.data.userInfo.email).isEmail(); | ||||
|               if(!validatesAsEmail){ // send validation failed if it's malformed..  y'know in general fuck em!
 | ||||
|               if(!validatesAsEmail){ | ||||
|                 // Subscription -> failed coz mail malformed..  y'know in general fuck em!
 | ||||
|                 console.warn("Dropped email subscription due to malformed email address"); | ||||
|                 context.client.json.send({ type: "COLLABROOM", | ||||
|                   data:{ | ||||
|  | @ -55,6 +56,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|                    } | ||||
|                 }); | ||||
|               } else { | ||||
|                 // Subscription -> Go for it
 | ||||
|                 console.debug ("Subscription: Wrote to the database and sent client a positive response ",context.message.data.userInfo.email); | ||||
| 
 | ||||
|                 exports.setAuthorEmail( | ||||
|  | @ -77,7 +79,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|                 }); | ||||
|               } | ||||
|             } else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == true) { | ||||
| 	      // Unsubscription
 | ||||
|               // Unsubscription -> Go for it
 | ||||
|               console.debug ("Unsubscription: Remove from the database and sent client a positive response ",context.message.data.userInfo.email); | ||||
| 
 | ||||
|               exports.unsetAuthorEmail( | ||||
|  | @ -99,7 +101,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|                  } | ||||
|               }); | ||||
|             } else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) { | ||||
| 	      // Unsubscription
 | ||||
|               // Unsubscription -> Send failed as email not found
 | ||||
|               console.debug ("Unsubscription: Send client a negative response ",context.message.data.userInfo.email); | ||||
| 
 | ||||
|               context.client.json.send({ type: "COLLABROOM", | ||||
|  | @ -121,7 +123,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|           console.debug(context.message); | ||||
| 
 | ||||
|           var userIdFound = false; | ||||
|           // does email Subscription already exist for this name and padID?
 | ||||
|           // does email Subscription already exist for this UserId?
 | ||||
|           db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){ | ||||
|             if(userIds){ | ||||
|               async.forEach(Object.keys(userIds), function(user, cb){ | ||||
|  | @ -129,7 +131,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|                   console.debug("Options for this pad ", userIds[user].authorId, " found in the Db"); | ||||
|                   userIdFound = true; | ||||
| 
 | ||||
|                   // We send back the options set for this user
 | ||||
|                   // We send back the options associated to this userId
 | ||||
|                   context.client.json.send({ type: "COLLABROOM", | ||||
|                     data:{ | ||||
|                       type: "emailNotificationGetUserInfo", | ||||
|  | @ -152,7 +154,7 @@ exports.handleMessage = function(hook_name, context, callback){ | |||
|           }); | ||||
| 
 | ||||
|           if (!userIdFound) { | ||||
|             // We send back the options set for this user
 | ||||
|             // No options set for this userId
 | ||||
|             context.client.json.send({ type: "COLLABROOM", | ||||
|               data:{ | ||||
|                 type: "emailNotificationGetUserInfo", | ||||
|  | @ -197,19 +199,26 @@ exports.setAuthorEmailRegistered = function(datas, authorId, padId){ | |||
| // Updates the database by removing the email record for that AuthorId
 | ||||
| exports.unsetAuthorEmail = function (author, datas, callback){ | ||||
|   db.get("globalAuthor:" + author, function(err, value){ // get the current value
 | ||||
| 
 | ||||
|     // Remove the email option from the datas
 | ||||
|     delete value['email']; | ||||
| 
 | ||||
|     // Write the modified datas back in the Db
 | ||||
|     db.set("globalAuthor:" + author, value); | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // Remove email and padId from the database
 | ||||
| // Remove email, options and padId from the database
 | ||||
| exports.unsetAuthorEmailRegistered = function(datas, authorId, padId){ | ||||
|   console.debug("unregistered", datas.email, " to ", padId); | ||||
|   // 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
 | ||||
|     delete value[datas.email]; // remove the registered values to the object
 | ||||
|     console.warn("written to database"); | ||||
|     db.set("emailSubscription:" + padId, value); // stick it in the database
 | ||||
|   }); | ||||
| 
 | ||||
|   db.get("emailSubscription:" + padId, function(err, value){ // get the current value
 | ||||
| 
 | ||||
|     // remove the registered options from the object
 | ||||
|     delete value[datas.email]; | ||||
| 
 | ||||
|     // Write the modified datas back in the Db
 | ||||
|     console.warn("written to database"); | ||||
|     db.set("emailSubscription:" + padId, value); | ||||
|   }); | ||||
| } | ||||
|  |  | |||
|  | @ -77,7 +77,7 @@ exports.notifyEnd = function(padId){ | |||
|       async.forEach(Object.keys(recipients), function(recipient, cb){ | ||||
|         // Is this recipient already on the pad?
 | ||||
|         exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the$
 | ||||
| 	  var onEnd = typeof(recipients[recipient].onEnd) == "undefined" || recipients[recipient].onEnd?true:false; // In case onEnd wasn't defined we set it to true
 | ||||
|           var onEnd = typeof(recipients[recipient].onEnd) == "undefined" || recipients[recipient].onEnd?true:false; // In case onEnd wasn't defined we set it to false
 | ||||
| 
 | ||||
|           if(!userIsOnPad && onEnd){ | ||||
|             console.debug("Emailing "+recipient +" about a pad finished being updated"); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 quenenni
						quenenni