fix a fucking bug

dependabot/npm_and_yarn/mixin-deep-1.3.2
panjunwen 6 years ago
parent d800317e2b
commit d6baa3b6f4
  1. 13
      cloud.js
  2. 7
      utilities/send-mail.js

@ -5,7 +5,9 @@ const request = require('request');
function sendNotification(currentComment) {
// 发送博主通知邮件
mail.notice(currentComment);
if (currentComment.get('mail') !== process.env.BLOGGER_EMAIL) {
mail.notice(currentComment);
}
// AT评论通知
// 获取评论内容
var comm = currentComment.get('comment');
@ -21,7 +23,12 @@ function sendNotification(currentComment) {
currentComment.set('rid', rid);
let query = new AV.Query('Comment');
query.get(rid).then(function (parentComment) {
mail.send(currentComment, parentComment);
if (parentComment.get('mail') && parentComment.get('mail') !== process.env.BLOGGER_EMAIL) {
mail.send(currentComment, parentComment);
} else {
console.log('被@者匿名,不会发送通知');
}
}, function (error) {
console.warn('获取@对象失败!');
});
@ -29,7 +36,7 @@ function sendNotification(currentComment) {
AV.Cloud.afterSave('Comment', function (request) {
let currentComment = request.object;
sendNotification(currentComment);
return sendNotification(currentComment);
});
AV.Cloud.define('resend-mails', function(request) {

@ -33,6 +33,9 @@ exports.notice = (comment) => {
if (error) {
return console.log(error);
}
console.log('博主通知邮件成功发送: %s', info.response);
currentComment.set('isNotified', true);
currentComment.save();
});
}
@ -42,7 +45,7 @@ exports.send = (currentComment, parentComment)=> {
let NICK = currentComment.get('nick');
let COMMENT = currentComment.get('comment');
let PARENT_COMMENT = parentComment.get('comment');
let POST_URL = process.env.SITE_URL + currentComment.get('url') + '#' + comment.get('objectId');
let POST_URL = process.env.SITE_URL + currentComment.get('url') + '#' + currentComment.get('objectId');
let SITE_URL = process.env.SITE_URL;
let _subject = process.env.MAIL_SUBJECT || '${PARENT_NICK},您在『${SITE_NAME}』上的评论收到了回复';
@ -61,7 +64,7 @@ exports.send = (currentComment, parentComment)=> {
if (error) {
return console.log(error);
}
console.log('邮件 %s 成功发送: %s', info.messageId, info.response);
console.log('AT通知邮件成功发送: %s', info.response);
currentComment.set('isNotified', true);
currentComment.save();
});

Loading…
Cancel
Save