Compare commits

..

No commits in common. "25a7c37395c66e6e018c873ef522b89c80af31be" and "9834f27b8e891bc140627eba296d1c2f6c5fd5ab" have entirely different histories.

5 changed files with 37 additions and 52 deletions

View file

@ -6,30 +6,25 @@ On Github : https://github.com/JohnMcLear/ep_email_notifications
# Installation
Make sure an SMTP gateway is installed IE postfix
Configure SPF and RDNS records to ensure proper mail flow <-- Search online
Copy/Edit the below to your settings.json
Connect to a pad, Click on the Share/Embed link and enter in your email address.
Open that pad in ANOTHER BROWSER then begin modifying, you should receive an email when the pad has begun editing and once the pad has gone stale (when everyone stops editing it and a time period passes).
NOTE: You will NOT receive an email if you(the author that registered their email) are currently on or editing that pad!
```
"ep_email_notifications" : {
"panelDisplayLocation": { // Where you want to have the subscription panel
"mysettings": true,
"popup": true
panelDisplayLocation: { // Where you want to have the subscription panel
mysettings: true, // In the "mysettings" menu
popup: true // A popup that pop in the bottom right corner of the pad after 10 seconds
},
"checkFrequency": "6000", // checkFrequency = How frequently(milliseconds) to check for pad updates -- Move me to the settings file
"staleTime": "30000", // staleTime = How stale(milliseconds) does a pad need to be before notifying subscribers? Move me to settings
"fromName": "Etherpad SETTINGS FILE!",
"fromEmail": "pad@etherpad.org",
"urlToPads": "http://beta.etherpad.org/p/", // urlToPads = The URL to your pads note the trailing /
"emailServer": { // See https://github.com/eleith/emailjs for settings
"host": "127.0.0.1"
checkFrequency: 6000, // checkFrequency = How frequently(milliseconds) to check for pad updates -- Move me to the settings file
staleTime: 30000, // staleTime = How stale(milliseconds) does a pad need to be before notifying subscribers? Move me to settings
fromName: "Etherpad SETTINGS FILE!",
fromEmail: "pad@etherpad.org",
urlToPads: "http://beta.etherpad.org/p/", // urlToPads = The URL to your pads note the trailing /
emailServer: { // See https://github.com/eleith/emailjs for settings
host: "127.0.0.1"
}
}
```

View file

@ -28,8 +28,9 @@ exports.handleMessage = function(hook_name, context, callback){
payload: true
}
});
console.error("Settings for ep_email_notifications plugin are missing in settings.json file");
return callback([null]); // don't run onto passing colorId or anything else to the message handler
console.warn("Settings for ep_email_notifications plugin are missing in settings.json file");
callback([null]); // don't run onto passing colorId or anything else to the message handler
} else if (context.message.data.userInfo){
if(context.message.data.userInfo.email){ // it contains email
@ -38,8 +39,6 @@ exports.handleMessage = function(hook_name, context, callback){
// does email (Un)Subscription already exist for this email address?
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){
console.debug("emailSubscription");
var alreadyExists = false;
if(userIds){
@ -102,7 +101,7 @@ exports.handleMessage = function(hook_name, context, callback){
}); // close db get
return 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
}
}
@ -148,7 +147,8 @@ exports.handleMessage = function(hook_name, context, callback){
);
}
});
return callback([null]);
callback([null]);
}
}
}
@ -173,7 +173,6 @@ exports.subscriptionEmail = function (context, email, emailFound, userInfo, padI
padId
);
console.debug("emailSubSucc");
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailSubscriptionSuccess",
@ -193,13 +192,13 @@ exports.subscriptionEmail = function (context, email, emailFound, userInfo, padI
subject: "Email subscription confirmation for pad "+padId
},
function(err, message) {
console.error(err || message);
console.log(err || message);
}
);
} else if (!validatesAsEmail) {
// Subscription -> failed coz mail malformed.. y'know in general fuck em!
console.debug("Dropped email subscription due to malformed email address");
console.warn("Dropped email subscription due to malformed email address");
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailSubscriptionSuccess",
@ -263,7 +262,7 @@ exports.unsubscriptionEmail = function (context, emailFound, userInfo, padId) {
subject: "Email unsubscription confirmation for pad "+padId
},
function(err, message) {
console.error(err || message);
console.log(err || message);
}
);
} else {
@ -299,19 +298,18 @@ exports.sendUserInfo = function (context, emailFound, email, userInfo) {
if (emailFound == true) {
// We send back the options associated to this userId
var msg = {
type: "emailNotificationGetUserInfo",
payload: {
email: email,
onStart: onStart,
onEnd: onEnd,
formName: context.message.data.userInfo.formName,
success:true
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailNotificationGetUserInfo",
payload: {
email: email,
onStart: onStart,
onEnd: onEnd,
formName: context.message.data.userInfo.formName,
success:true
}
}
}
context.client.json.send({ type: "COLLABROOM", data: msg });
});
} else {
// No options set for this userId
context.client.json.send({ type: "COLLABROOM",

View file

@ -8,8 +8,7 @@ db['dbSettings'].cache = 0;
exports.registerRoute = function (hook_name, args, callback) {
// Catching (un)subscribe addresses
args.app.get(/\/p\/.*\/(un){0,1}subscribe=(.*)/, function(req, res) {
console.warn("HERE");
args.app.get('/p/*/(un){0,1}subscribe=*', function(req, res) {
var fullURL = req.protocol + "://" + req.get('host') + req.url;
var path=req.url.split("/");
var padId=path[2];

View file

@ -1,7 +1,7 @@
{
"name": "ep_email_notifications",
"description": "Subscribe to a pad and receive an email when someone edits your pad",
"version": "0.1.4",
"version": "0.1.1",
"author": {
"name": "John Mclear",
"email": "john@mclear.co.uk",

View file

@ -4,8 +4,7 @@
async = require('../../src/node_modules/async'),
check = require('validator').check,
email = require('emailjs'),
settings = require('../../src/node/utils/Settings'),
util = require('util');
settings = require('../../src/node/utils/Settings');
// Settings -- EDIT THESE IN settings.json not here..
var pluginSettings = settings.ep_email_notifications;
@ -23,8 +22,6 @@ var timers = {};
// 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 emailFooter = "\nYou can unsubscribe from these emails in the pad's Settings window.\n";
exports.padUpdate = function (hook_name, _pad) {
if (areParamsOk == false) return false;
@ -44,11 +41,6 @@ exports.padUpdate = function (hook_name, _pad) {
}
};
padUrl = function(padId, fmt) {
fmt = fmt || "%s";
return util.format(fmt, urlToPads + padId);
}
exports.notifyBegin = function(padId){
console.warn("Getting pad email stuff for "+padId);
db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
@ -62,7 +54,7 @@ exports.notifyBegin = function(padId){
if(!userIsOnPad && onStart){
console.debug("Emailing "+recipient +" about a new begin update");
server.send({
text: "This pad is now being edited:\n" + padUrl(padId, " <%s>\n") + emailFooter,
text: "Your pad at "+urlToPads+padId +" is being edited, we're just emailing you let you know :)",
from: fromName+ "<"+fromEmail+">",
to: recipient,
subject: "Someone started editing "+padId
@ -83,7 +75,8 @@ exports.notifyBegin = function(padId){
}
exports.notifyEnd = function(padId){
// TODO: get the modified contents to include in the email
// get the modified contents...
var changesToPad = "Functionality does not exist";
db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
if(recipients){
@ -97,7 +90,7 @@ exports.notifyEnd = function(padId){
if(!userIsOnPad && onEnd){
console.debug("Emailing "+recipient +" about a pad finished being updated");
server.send({
text: "This pad is done being edited:\n" + padUrl(padId, " <%s>\n") + emailFooter,
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,
from: fromName+ "<"+fromEmail+">",
to: recipient,
subject: "Someone finished editing "+padId