dirtyish way of handling a cookie to stop re-prompt
This commit is contained in:
parent
aeb44eb8ca
commit
f4d455a751
3 changed files with 9 additions and 4 deletions
|
@ -22,7 +22,6 @@ Open that pad in ANOTHER BROWSER then begin modifying, you should recieve an ema
|
||||||
```
|
```
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
* stop the ui prompting if already subscribed
|
|
||||||
* Clean up all code
|
* Clean up all code
|
||||||
* Stop it emailing me if I'm already on the pad
|
* Stop it emailing me if I'm already on the pad
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var cookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
|
||||||
|
|
||||||
if(typeof exports == 'undefined'){
|
if(typeof exports == 'undefined'){
|
||||||
var exports = this['mymodule'] = {};
|
var exports = this['mymodule'] = {};
|
||||||
}
|
}
|
||||||
|
@ -28,7 +30,10 @@ function init(){
|
||||||
if(clientHasAlreadyRegistered()){ // if the client has already registered for emails on this pad.
|
if(clientHasAlreadyRegistered()){ // if the client has already registered for emails on this pad.
|
||||||
// showAlreadyRegistered(); // client has already registered, let em know..
|
// showAlreadyRegistered(); // client has already registered, let em know..
|
||||||
}else{
|
}else{
|
||||||
askClientToEnterEmail(); // ask the client to register TODO uncomment me for a pop up
|
var cookieVal = pad.getPadId() + "email";
|
||||||
|
if(cookie.getPref(cookieVal) !== "true"){ // if this user hasn't already subscribed
|
||||||
|
askClientToEnterEmail(); // ask the client to register TODO uncomment me for a pop up
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +76,7 @@ function askClientToEnterEmail(){
|
||||||
// (string | mandatory) the heading of the notification
|
// (string | mandatory) the heading of the notification
|
||||||
title: "Enter your email to recieve an email when someone modifies this pad",
|
title: "Enter your email to recieve an email when someone modifies this pad",
|
||||||
// (string | mandatory) the text inside the notification
|
// (string | mandatory) the text inside the notification
|
||||||
text: "<form class='ep_email_form'><label for='ep_email'><input id='ep_email_notification' placeholder='your@email.com' style='padding:5px;width:200px;' type=email><input type=submit value=subscribe style='padding:5px;'></form>",
|
text: "<form class='ep_email_form'><label for='ep_email'><input id='ep_email_notification' placeholder='your@email.com' style='padding:5px;width:180px;' type=email><input type=submit value=subscribe style='padding:5px;'></form>",
|
||||||
// (bool | optional) if you want it to fade out on its own or just sit there
|
// (bool | optional) if you want it to fade out on its own or just sit there
|
||||||
sticky: true,
|
sticky: true,
|
||||||
// (int | optional) the time you want it to be alive for before fading out
|
// (int | optional) the time you want it to be alive for before fading out
|
||||||
|
@ -101,6 +106,7 @@ function sendEmailToServer(){
|
||||||
message.userInfo.userId = userId;
|
message.userInfo.userId = userId;
|
||||||
if(email){
|
if(email){
|
||||||
pad.collabClient.sendMessage(message);
|
pad.collabClient.sendMessage(message);
|
||||||
|
cookie.setPref(message.padId+"email", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ exports.notifyEnd = function(padId){
|
||||||
db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
|
db.get("emailSubscription:" + padId, function(err, recipients){ // get everyone we need to email
|
||||||
if(recipients){
|
if(recipients){
|
||||||
async.forEach(Object.keys(recipients), function(recipient, cb){
|
async.forEach(Object.keys(recipients), function(recipient, cb){
|
||||||
console.debug("Emailing "+recipient +" about a new begin update");
|
console.warn("Emailing "+recipient +" about a pad finish editing");
|
||||||
|
|
||||||
server.send({
|
server.send({
|
||||||
text: "Your pad at "+urlToPads+padId +" has finished being edited, we're just emailing you let you know :) The changes look like this:" + changesToPad,
|
text: "Your pad at "+urlToPads+padId +" has finished being edited, we're just emailing you let you know :) The changes look like this:" + changesToPad,
|
||||||
|
|
Loading…
Reference in a new issue