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();
|
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) {
|
exports.eejsBlock_mySettings = function (hook_name, args, cb) {
|
||||||
args.content = args.content + eejs.require('ep_email_notifications/templates/email_notifications_settings.ejs');
|
args.content = args.content + eejs.require('ep_email_notifications/templates/email_notifications_settings.ejs');
|
||||||
return cb();
|
return cb();
|
||||||
|
@ -20,4 +13,3 @@ exports.eejsBlock_mySettings = function (hook_name, args, cb) {
|
||||||
exports.eejsBlock_styles = 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">';
|
args.content = args.content + '<link href="../static/plugins/ep_email_notifications/static/css/email_notifications.css" rel="stylesheet">';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
4
ep.json
4
ep.json
|
@ -6,8 +6,8 @@
|
||||||
"padUpdate": "ep_email_notifications/update",
|
"padUpdate": "ep_email_notifications/update",
|
||||||
"handleMessage": "ep_email_notifications/handleMessage",
|
"handleMessage": "ep_email_notifications/handleMessage",
|
||||||
"eejsBlock_scripts": "ep_email_notifications/client",
|
"eejsBlock_scripts": "ep_email_notifications/client",
|
||||||
"eejsBlock_mySettings": "ep_email_notifications/client:eejsBlock_mySettings",
|
"eejsBlock_mySettings": "ep_email_notifications/client:eejsBlock_mySettings",
|
||||||
"eejsBlock_styles": "ep_email_notifications/client:eejsBlock_styles"
|
"eejsBlock_styles": "ep_email_notifications/client:eejsBlock_styles"
|
||||||
},
|
},
|
||||||
"client_hooks": {
|
"client_hooks": {
|
||||||
"postAceInit":"ep_email_notifications/static/js/ep_email:postAceInit",
|
"postAceInit":"ep_email_notifications/static/js/ep_email:postAceInit",
|
||||||
|
|
|
@ -33,20 +33,21 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
}); // end async for each
|
}); // end async for each
|
||||||
}
|
}
|
||||||
|
|
||||||
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
|
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
|
||||||
// SUbscription
|
// SUbscription
|
||||||
console.debug("email ", context.message.data.userInfo.email, "already subscribed to ", context.message.data.padId, " so sending message to client");
|
console.debug("email ", context.message.data.userInfo.email, "already subscribed to ", context.message.data.padId, " so sending message to client");
|
||||||
|
|
||||||
context.client.json.send({ type: "COLLABROOM",
|
context.client.json.send({ type: "COLLABROOM",
|
||||||
data:{
|
data:{
|
||||||
type: "emailSubscriptionSuccess",
|
type: "emailSubscriptionSuccess",
|
||||||
payload: false
|
payload: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == false){
|
} else if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == false){
|
||||||
// SUbscription
|
// SUbscription
|
||||||
var validatesAsEmail = check(context.message.data.userInfo.email).isEmail();
|
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");
|
console.warn("Dropped email subscription due to malformed email address");
|
||||||
context.client.json.send({ type: "COLLABROOM",
|
context.client.json.send({ type: "COLLABROOM",
|
||||||
data:{
|
data:{
|
||||||
|
@ -55,12 +56,13 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Subscription -> Go for it
|
||||||
console.debug ("Subscription: Wrote to the database and sent client a positive response ",context.message.data.userInfo.email);
|
console.debug ("Subscription: Wrote to the database and sent client a positive response ",context.message.data.userInfo.email);
|
||||||
|
|
||||||
exports.setAuthorEmail(
|
exports.setAuthorEmail(
|
||||||
context.message.data.userInfo.userId,
|
context.message.data.userInfo.userId,
|
||||||
context.message.data.userInfo,
|
context.message.data.userInfo,
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.setAuthorEmailRegistered(
|
exports.setAuthorEmailRegistered(
|
||||||
|
@ -75,15 +77,15 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
payload: true
|
payload: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == true) {
|
} 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);
|
console.debug ("Unsubscription: Remove from the database and sent client a positive response ",context.message.data.userInfo.email);
|
||||||
|
|
||||||
exports.unsetAuthorEmail(
|
exports.unsetAuthorEmail(
|
||||||
context.message.data.userInfo.userId,
|
context.message.data.userInfo.userId,
|
||||||
context.message.data.userInfo,
|
context.message.data.userInfo,
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.unsetAuthorEmailRegistered(
|
exports.unsetAuthorEmailRegistered(
|
||||||
|
@ -98,17 +100,17 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
payload: true
|
payload: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) {
|
} 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);
|
console.debug ("Unsubscription: Send client a negative response ",context.message.data.userInfo.email);
|
||||||
|
|
||||||
context.client.json.send({ type: "COLLABROOM",
|
context.client.json.send({ type: "COLLABROOM",
|
||||||
data:{
|
data:{
|
||||||
type: "emailUnsubscriptionSuccess",
|
type: "emailUnsubscriptionSuccess",
|
||||||
payload: false
|
payload: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}); // close db get
|
}); // close db get
|
||||||
|
|
||||||
callback([null]); // don't run onto passing colorId or anything else to the message handler
|
callback([null]); // don't run onto passing colorId or anything else to the message handler
|
||||||
|
@ -121,7 +123,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
console.debug(context.message);
|
console.debug(context.message);
|
||||||
|
|
||||||
var userIdFound = false;
|
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){
|
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){
|
||||||
if(userIds){
|
if(userIds){
|
||||||
async.forEach(Object.keys(userIds), function(user, cb){
|
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");
|
console.debug("Options for this pad ", userIds[user].authorId, " found in the Db");
|
||||||
userIdFound = true;
|
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",
|
context.client.json.send({ type: "COLLABROOM",
|
||||||
data:{
|
data:{
|
||||||
type: "emailNotificationGetUserInfo",
|
type: "emailNotificationGetUserInfo",
|
||||||
|
@ -152,13 +154,13 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userIdFound) {
|
if (!userIdFound) {
|
||||||
// We send back the options set for this user
|
// No options set for this userId
|
||||||
context.client.json.send({ type: "COLLABROOM",
|
context.client.json.send({ type: "COLLABROOM",
|
||||||
data:{
|
data:{
|
||||||
type: "emailNotificationGetUserInfo",
|
type: "emailNotificationGetUserInfo",
|
||||||
payload: {
|
payload: {
|
||||||
success:false
|
success:false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -197,19 +199,26 @@ exports.setAuthorEmailRegistered = function(datas, authorId, padId){
|
||||||
// Updates the database by removing the email record for that AuthorId
|
// Updates the database by removing the email record for that AuthorId
|
||||||
exports.unsetAuthorEmail = function (author, datas, callback){
|
exports.unsetAuthorEmail = function (author, datas, callback){
|
||||||
db.get("globalAuthor:" + author, function(err, value){ // get the current value
|
db.get("globalAuthor:" + author, function(err, value){ // get the current value
|
||||||
|
|
||||||
|
// Remove the email option from the datas
|
||||||
delete value['email'];
|
delete value['email'];
|
||||||
|
|
||||||
|
// Write the modified datas back in the Db
|
||||||
db.set("globalAuthor:" + author, value);
|
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){
|
exports.unsetAuthorEmailRegistered = function(datas, authorId, padId){
|
||||||
console.debug("unregistered", datas.email, " to ", 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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
.ep_email_settings {
|
.ep_email_settings {
|
||||||
display: none;
|
display: none;
|
||||||
padding-left: 1.5em;
|
padding-left: 1.5em;
|
||||||
padding: .2em;
|
padding: .2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ep_email_input {
|
.ep_email_input {
|
||||||
padding:.2em;
|
padding:.2em;
|
||||||
width:177px;
|
width:177px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,14 @@ exports.postAceInit = function(hook, context){
|
||||||
|
|
||||||
// Prepare subscription before submit form
|
// Prepare subscription before submit form
|
||||||
$('#ep_email_subscribe').on('click', function() {
|
$('#ep_email_subscribe').on('click', function() {
|
||||||
$('#ep_email_option').val('subscribe');
|
$('#ep_email_option').val('subscribe');
|
||||||
checkAndSend();
|
checkAndSend();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prepare unsubscription before submit form
|
// Prepare unsubscription before submit form
|
||||||
$('#ep_email_unsubscribe').on('click', function() {
|
$('#ep_email_unsubscribe').on('click', function() {
|
||||||
$('#ep_email_option').val('unsubscribe');
|
$('#ep_email_option').val('unsubscribe');
|
||||||
checkAndSend();
|
checkAndSend();
|
||||||
});
|
});
|
||||||
|
|
||||||
// subscribe by email can be active..
|
// subscribe by email can be active..
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
<input type="checkbox" id="options-emailNotifications"></input>
|
<input type="checkbox" id="options-emailNotifications"></input>
|
||||||
<label for="options-emailNotifications">Email Notifications</label>
|
<label for="options-emailNotifications">Email Notifications</label>
|
||||||
<div class="ep_email_settings">
|
<div class="ep_email_settings">
|
||||||
<form class='ep_email_form'>
|
<form class='ep_email_form'>
|
||||||
<input id='ep_email' class='ep_email_input' placeholder='your@email.com' type=email>
|
<input id='ep_email' class='ep_email_input' placeholder='your@email.com' type=email>
|
||||||
<label>Send a mail when someone..</label>
|
<label>Send a mail when someone..</label>
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onStart"></input>
|
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onStart"></input>
|
||||||
<label for="ep_email_onStart">starts editing the pad</label>
|
<label for="ep_email_onStart">starts editing the pad</label>
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onEnd"></input>
|
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onEnd"></input>
|
||||||
<label for="ep_email_onEnd">finish editing the pad</label>
|
<label for="ep_email_onEnd">finish editing the pad</label>
|
||||||
<input id='ep_email_option'type=hidden >
|
<input id='ep_email_option'type=hidden >
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
<input style="padding:5px;" id='ep_email_subscribe' type=button value=subscribe>
|
<input style="padding:5px;" id='ep_email_subscribe' type=button value=subscribe>
|
||||||
<input style="padding:5px;" id='ep_email_unsubscribe'type=button value=unsubscribe>
|
<input style="padding:5px;" id='ep_email_unsubscribe'type=button value=unsubscribe>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -45,8 +45,8 @@ exports.notifyBegin = function(padId){
|
||||||
async.forEach(Object.keys(recipients), function(recipient, cb){
|
async.forEach(Object.keys(recipients), function(recipient, cb){
|
||||||
// Is this recipient already on the pad?
|
// Is this recipient already on the pad?
|
||||||
exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the pad?
|
exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the pad?
|
||||||
var onStart = typeof(recipients[recipient].onStart) == "undefined" || recipients[recipient].onStart?true:false; // In case onStart wasn't defined we set it to true
|
var onStart = typeof(recipients[recipient].onStart) == "undefined" || recipients[recipient].onStart?true:false; // In case onStart wasn't defined we set it to true
|
||||||
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: "Your pad at "+urlToPads+padId +" is being edited, we're just emailing you let you know :)",
|
||||||
|
@ -77,7 +77,7 @@ exports.notifyEnd = function(padId){
|
||||||
async.forEach(Object.keys(recipients), function(recipient, cb){
|
async.forEach(Object.keys(recipients), function(recipient, cb){
|
||||||
// Is this recipient already on the pad?
|
// Is this recipient already on the pad?
|
||||||
exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the$
|
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){
|
if(!userIsOnPad && onEnd){
|
||||||
console.debug("Emailing "+recipient +" about a pad finished being updated");
|
console.debug("Emailing "+recipient +" about a pad finished being updated");
|
||||||
|
|
Loading…
Reference in a new issue