Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
DesertsPan committed Sep 18, 2018
1 parent 85a962e commit b167fd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ AV.Cloud.afterSave('Comment', function (request) {
AV.Cloud.define('resend-mails', function(request) {
let query = new AV.Query(Comment);
query.greaterThanOrEqualTo('createdAt', new Date(new Date().getTime() - 24*60*60*1000));
query.notEqualTo('isNotified', true);
// 如果你的评论量很大,可以适当调高数量限制,最高1000
query.limit(200);
return query.find().then(function(results) {
new Promise((resolve, reject)=>{
count = 0;
count = results.length;
for (var i = 0; i < results.length; i++ ) {
if (!results[i].get('isNotified')){
sendNotification(results[i]);
count++;
}
sendNotification(results[i]);
}
resolve(count);
}).then((count)=>{
Expand Down
2 changes: 2 additions & 0 deletions utilities/send-mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ exports.notice = (comment) => {
return console.log(error);
}
console.log('通知邮件发送成功!');
comment.set('isNotified', true);
comment.save();
});
}

Expand Down

0 comments on commit b167fd5

Please sign in to comment.