Compare commits

...

11 commits

Author SHA1 Message Date
John McLear
25a7c37395 Merge pull request #31 from brettcs/email-copyediting
update: Improve email text.
2017-08-31 09:27:12 +01:00
Brett Smith
63403293d0 update: Improve email text.
* Make the text less verbose.
* Tell the reader how to unsubscribe.
* Remove the placeholder for document changes.
2017-08-30 12:40:46 -04:00
John McLear
96410df84c bump v 2015-06-25 11:49:29 +01:00
John McLear
96f60c972f Merge pull request #25 from cbarillet/master
Fix regexp to catch (un)subscribe addresses
2015-06-02 12:00:20 +01:00
Cyril Barillet
f2194aab20 Fix regexp to catch (un)subscribe addresses 2015-06-02 08:07:15 +02:00
John McLear
2bbf245d83 make it work again 2015-05-05 20:37:00 +01:00
John McLear
20c1ae0853 begin fixing plugin 2015-05-03 12:48:15 +01:00
John McLear
f515f19ef0 Merge pull request #20 from Yaco/master
fixed instructions
2014-03-17 23:38:27 +00:00
Yaco
85fd43037e fixed instructions 2014-03-17 20:36:41 -03:00
John McLear
77a81edb55 Merge pull request #19 from Yaco/master
bumped to 0.1.2
2014-03-17 23:35:29 +00:00
Yaco
c59def8afe bumped to 0.1.2 2014-03-17 20:33:25 -03:00
5 changed files with 52 additions and 37 deletions

View file

@ -6,25 +6,30 @@ 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, // In the "mysettings" menu
popup: true // A popup that pop in the bottom right corner of the pad after 10 seconds
"panelDisplayLocation": { // Where you want to have the subscription panel
"mysettings": true,
"popup": true
},
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,9 +28,8 @@ exports.handleMessage = function(hook_name, context, callback){
payload: true
}
});
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
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
} else if (context.message.data.userInfo){
if(context.message.data.userInfo.email){ // it contains email
@ -39,6 +38,8 @@ 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){
@ -101,7 +102,7 @@ exports.handleMessage = function(hook_name, context, callback){
}); // close db get
callback([null]); // don't run onto passing colorId or anything else to the message handler
return callback([null]); // don't run onto passing colorId or anything else to the message handler
}
}
@ -147,8 +148,7 @@ exports.handleMessage = function(hook_name, context, callback){
);
}
});
callback([null]);
return callback([null]);
}
}
}
@ -173,6 +173,7 @@ exports.subscriptionEmail = function (context, email, emailFound, userInfo, padI
padId
);
console.debug("emailSubSucc");
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailSubscriptionSuccess",
@ -192,13 +193,13 @@ exports.subscriptionEmail = function (context, email, emailFound, userInfo, padI
subject: "Email subscription confirmation for pad "+padId
},
function(err, message) {
console.log(err || message);
console.error(err || message);
}
);
} else if (!validatesAsEmail) {
// Subscription -> failed coz mail malformed.. y'know in general fuck em!
console.warn("Dropped email subscription due to malformed email address");
console.debug("Dropped email subscription due to malformed email address");
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailSubscriptionSuccess",
@ -262,7 +263,7 @@ exports.unsubscriptionEmail = function (context, emailFound, userInfo, padId) {
subject: "Email unsubscription confirmation for pad "+padId
},
function(err, message) {
console.log(err || message);
console.error(err || message);
}
);
} else {
@ -298,18 +299,19 @@ exports.sendUserInfo = function (context, emailFound, email, userInfo) {
if (emailFound == true) {
// We send back the options associated to this userId
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailNotificationGetUserInfo",
payload: {
email: email,
onStart: onStart,
onEnd: onEnd,
formName: context.message.data.userInfo.formName,
success:true
}
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: msg });
} else {
// No options set for this userId
context.client.json.send({ type: "COLLABROOM",

View file

@ -8,7 +8,8 @@ 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) {
args.app.get(/\/p\/.*\/(un){0,1}subscribe=(.*)/, function(req, res) {
console.warn("HERE");
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.1",
"version": "0.1.4",
"author": {
"name": "John Mclear",
"email": "john@mclear.co.uk",

View file

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