Small corrections
- put back msgs to the debug level instead of info - remove a call to ep_etherpad-lite/node/utils/Settings as it was for a function that doesn't exist anymore - remove checked_state var for the form as I manage myself the default check for the options.
This commit is contained in:
parent
53c1df8248
commit
907ecb9a7b
2 changed files with 7 additions and 12 deletions
|
@ -1,6 +1,4 @@
|
||||||
var eejs = require("ep_etherpad-lite/node/eejs");
|
var eejs = require("ep_etherpad-lite/node/eejs");
|
||||||
var settings = require('ep_etherpad-lite/node/utils/Settings');
|
|
||||||
var checked_state = '';
|
|
||||||
|
|
||||||
exports.eejsBlock_scripts = function (hook_name, args, cb) {
|
exports.eejsBlock_scripts = function (hook_name, args, cb) {
|
||||||
args.content = args.content + eejs.require("ep_email_notifications/templates/scripts.html", {}, module);
|
args.content = args.content + eejs.require("ep_email_notifications/templates/scripts.html", {}, module);
|
||||||
|
@ -15,7 +13,7 @@ exports.eejsBlock_embedPopup = function (hook_name, args, 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', {checked : checked_state});
|
args.content = args.content + eejs.require('ep_email_notifications/templates/email_notifications_settings.ejs');
|
||||||
return cb();
|
return cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,14 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
if (context.message.data.userInfo){
|
if (context.message.data.userInfo){
|
||||||
if(context.message.data.userInfo.email){ // it contains email
|
if(context.message.data.userInfo.email){ // it contains email
|
||||||
console.debug(context.message);
|
console.debug(context.message);
|
||||||
console.info("ep_mail: " + context.message.data.userInfo.email + " / " + context.message.data.userInfo.email_option);
|
|
||||||
console.info(context.message.data.userInfo);
|
|
||||||
|
|
||||||
// does email Subscription already exist for this email address?
|
// does email Subscription already exist for this email address?
|
||||||
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){
|
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){
|
||||||
|
|
||||||
var alreadyExists = false;
|
var alreadyExists = false;
|
||||||
console.info(userIds);
|
|
||||||
if(userIds){
|
if(userIds){
|
||||||
async.forEach(Object.keys(userIds), function(user, cb){
|
async.forEach(Object.keys(userIds), function(user, cb){
|
||||||
console.info("UserIds subscribed by email to this pad:", userIds);
|
console.debug("UserIds subscribed by email to this pad:", userIds);
|
||||||
if(user == context.message.data.userInfo.email){ // If we already have this email registered for this pad
|
if(user == context.message.data.userInfo.email){ // If we already have this email registered for this pad
|
||||||
// This user ID is already assigned to this padId so don't do anything except tell the user they are already subscribed somehow..
|
// This user ID is already assigned to this padId so don't do anything except tell the user they are already subscribed somehow..
|
||||||
alreadyExists = true;
|
alreadyExists = true;
|
||||||
|
@ -38,7 +35,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
|
|
||||||
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
|
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
|
||||||
// SUbscription
|
// SUbscription
|
||||||
console.info("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:{
|
||||||
|
@ -58,7 +55,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.info ("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,
|
||||||
|
@ -81,7 +78,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
}
|
}
|
||||||
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == true) {
|
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == true) {
|
||||||
// Unsubscription
|
// Unsubscription
|
||||||
console.info ("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,
|
||||||
|
@ -103,7 +100,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
});
|
});
|
||||||
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) {
|
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) {
|
||||||
// Unsubscription
|
// Unsubscription
|
||||||
console.info ("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:{
|
||||||
|
@ -129,7 +126,7 @@ exports.handleMessage = function(hook_name, context, callback){
|
||||||
if(userIds){
|
if(userIds){
|
||||||
async.forEach(Object.keys(userIds), function(user, cb){
|
async.forEach(Object.keys(userIds), function(user, cb){
|
||||||
if(userIds[user].authorId == context.message.data.userInfo.userId){ // if we find the same Id in the Db as the one used by the user
|
if(userIds[user].authorId == context.message.data.userInfo.userId){ // if we find the same Id in the Db as the one used by the user
|
||||||
console.info("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 set for this user
|
||||||
|
|
Loading…
Reference in a new issue