Fixing issues with e-mail and status update.

This commit is contained in:
David Jay
2017-01-06 15:35:32 -05:00
parent 9e651a9292
commit d5a82f04c2
5 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -16,10 +16,10 @@ export const userStatusUpdate = (status, userId, commentId) => {
};
// change status of a user
export const sendNotificationEmail = (userId, subject, text) => {
export const sendNotificationEmail = (userId, subject, body) => {
return (dispatch, getState) => {
const _csrf = getState().auth.get('_csrf');
return coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, text}, _csrf})
return coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}, _csrf})
.catch(error => dispatch({type: userTypes.USER_EMAIL_FAILURE, error}));
};
};
+1 -1
View File
@@ -94,7 +94,7 @@
"send": "Send",
"bio": "bio",
"username": "username",
"subject": "Your account has been suspended",
"email_subject": "Your account has been suspended",
"email": "Another member of the community recently flagged your {0} for review. Because of its content your {0} was rejected. This means you can no longer comment, like, or flag content until you rewrite your {0}. Please e-mail moderator@newsorg.com if you have any questions or concerns.",
"write_message": "Write a message"
},
+3 -2
View File
@@ -437,7 +437,7 @@ UserService.setStatus = (id, status, comment_id) => {
}
// If ban then reject the comment and update status
if (status === 'banned') {
if (status === 'banned' || status === 'suspended') {
return UserModel.update({
id: id
}, {
@@ -446,7 +446,8 @@ UserService.setStatus = (id, status, comment_id) => {
}
})
.then(() => {
return Comment.pushStatus(comment_id, 'rejected', id);
return comment_id ? Comment.pushStatus(comment_id, 'rejected', id) :
Promise.resolve();
});
}
+3 -4
View File
@@ -67,17 +67,16 @@ router.post('/:user_id/status', parseForm, csrfProtection, (req, res, next) => {
});
router.post('/:user_id/email', authorization.needed('admin'), parseForm, csrfProtection, (req, res, next) => {
User.find(req.user_id)
User.findById(req.params.user_id)
.then(user => {
const options = {
subject: req.subject,
subject: req.body.subject,
from: process.env.TALK_SMTP_FROM_ADDRESS,
to: user.email,
html: notificationEmailTemplate({
body: req.body
body: req.body.body
})
};
return mailer.sendSimple(options);
})
.then(() => {
+1 -1
View File
@@ -48,7 +48,7 @@ const mailer = {
if (!subject) {
reject('sendSimple requires a subject for the email');
}
return resolve(transporter.sendMail({from, to, subject, text, html}));
});
}