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,7 +459,7 @@ 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: [
|
||||||
@ -470,9 +470,11 @@ function commentSave(comment, Context, res, next) {
|
|||||||
].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: {
|
||||||
@ -492,8 +494,11 @@ function commentSave(comment, Context, res, next) {
|
|||||||
].join('\n')
|
].join('\n')
|
||||||
};
|
};
|
||||||
transporter.sendMail(mailOptions, function (err) {
|
transporter.sendMail(mailOptions, function (err) {
|
||||||
if (err) { return 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