camper news reply emails go out to original story poster and poster of replied-to comment, works with old stories as well
This commit is contained in:
@ -155,7 +155,7 @@ exports.returnIndividualStory = function(req, res, next) {
|
|||||||
title: story.headline,
|
title: story.headline,
|
||||||
link: story.link,
|
link: story.link,
|
||||||
originalStoryLink: dashedName,
|
originalStoryLink: dashedName,
|
||||||
originalStoryAuthorEmail: story.author.email,
|
originalStoryAuthorEmail: story.author.email || "",
|
||||||
author: story.author,
|
author: story.author,
|
||||||
description: story.description,
|
description: story.description,
|
||||||
rank: story.upVotes.length,
|
rank: story.upVotes.length,
|
||||||
@ -345,7 +345,8 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
comments: [],
|
comments: [],
|
||||||
image: data.image,
|
image: data.image,
|
||||||
storyLink: storyLink,
|
storyLink: storyLink,
|
||||||
metaDescription: data.storyMetaDescription
|
metaDescription: data.storyMetaDescription,
|
||||||
|
originalStoryAuthorEmail: req.user.email
|
||||||
});
|
});
|
||||||
|
|
||||||
req.user.progressTimestamps.push(Date.now());
|
req.user.progressTimestamps.push(Date.now());
|
||||||
@ -449,8 +450,7 @@ function commentSave(comment, Context, res, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (data.originalStoryAuthorEmail !== recipient.email) {
|
if (data.originalStoryAuthorEmail && (data.originalStoryAuthorEmail !== recipient.email)) {
|
||||||
console.log("in mailer", data);
|
|
||||||
var transporter = nodemailer.createTransport({
|
var transporter = nodemailer.createTransport({
|
||||||
service: 'Mandrill',
|
service: 'Mandrill',
|
||||||
auth: {
|
auth: {
|
||||||
@ -459,41 +459,46 @@ function commentSave(comment, Context, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var mailOptions = {
|
var mailOptions = {
|
||||||
to: data.originalStoryAuthorEmail,
|
to: data.originalStoryAuthorEmail + ',' + recipient.email,
|
||||||
from: 'Team@freecodecamp.com',
|
from: 'Team@freecodecamp.com',
|
||||||
subject: associatedStory.author.username + " replied to your post on Camper News",
|
subject: associatedStory.author.username + " replied to your post on Camper News",
|
||||||
text: [
|
text: [
|
||||||
"Just a quick heads-up: " + associatedStory.author.username + " replied to you on Camper News.",
|
"Just a quick heads-up: " + associatedStory.author.username + " replied to you on Camper News.",
|
||||||
"You can keep this conversation going.",
|
"You can keep this conversation going.",
|
||||||
"Just head back to the discussion here: http://freecodecamp.com/stories/"+ comment.originalStoryLink,
|
"Just head back to the discussion here: http://freecodecamp.com/stories/" + comment.originalStoryLink,
|
||||||
'- the Free Code Camp Volunteer Team'
|
'- the Free Code Camp Volunteer Team'
|
||||||
].join('\n')
|
].join('\n')
|
||||||
};
|
};
|
||||||
transporter.sendMail(mailOptions, function(err) {
|
transporter.sendMail(mailOptions, function (err) {
|
||||||
if (err) { return err; }
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
var transporter = nodemailer.createTransport({
|
var transporter = nodemailer.createTransport({
|
||||||
service: 'Mandrill',
|
service: 'Mandrill',
|
||||||
auth: {
|
auth: {
|
||||||
user: secrets.mandrill.user,
|
user: secrets.mandrill.user,
|
||||||
pass: secrets.mandrill.password
|
pass: secrets.mandrill.password
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var mailOptions = {
|
||||||
|
to: recipient.email,
|
||||||
|
from: 'Team@freecodecamp.com',
|
||||||
|
subject: associatedStory.author.username + " replied to your post on Camper News",
|
||||||
|
text: [
|
||||||
|
"Just a quick heads-up: " + associatedStory.author.username + " replied to you on Camper News.",
|
||||||
|
"You can keep this conversation going.",
|
||||||
|
"Just head back to the discussion here: http://freecodecamp.com/stories/" + comment.originalStoryLink,
|
||||||
|
'- the Free Code Camp Volunteer Team'
|
||||||
|
].join('\n')
|
||||||
|
};
|
||||||
|
transporter.sendMail(mailOptions, function (err) {
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
var mailOptions = {
|
|
||||||
to: recipient.email,
|
|
||||||
from: 'Team@freecodecamp.com',
|
|
||||||
subject: associatedStory.author.username + " replied to your post on Camper News",
|
|
||||||
text: [
|
|
||||||
"Just a quick heads-up: " + associatedStory.author.username + " replied to you on Camper News.",
|
|
||||||
"You can keep this conversation going.",
|
|
||||||
"Just head back to the discussion here: http://freecodecamp.com/stories/"+ comment.originalStoryLink,
|
|
||||||
'- the Free Code Camp Volunteer Team'
|
|
||||||
].join('\n')
|
|
||||||
};
|
|
||||||
transporter.sendMail(mailOptions, function(err) {
|
|
||||||
if (err) { return err; }
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
});
|
});
|
||||||
var submitCommentToCommentHandler = function submitCommentToCommentHandler() {
|
var submitCommentToCommentHandler = function submitCommentToCommentHandler() {
|
||||||
$('#submit-comment-to-comment').unbind('click');
|
$('#submit-comment-to-comment').unbind('click');
|
||||||
|
console.log('in comments.jade', originalStoryAuthorEmail);
|
||||||
$.post('/stories/comment/' + commentId + '/comment',
|
$.post('/stories/comment/' + commentId + '/comment',
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
|
Reference in New Issue
Block a user