mirror of
https://github.com/wassname/talk.git
synced 2026-07-28 11:27:05 +08:00
Fixing issues with e-mail and status update.
This commit is contained in:
@@ -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}));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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}));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user