Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let ip = currentComment.get('ip') || defaultIp;
console.log('IP: %s', ip);
spam.checkSpam(currentComment, ip);
// AT评论通知
let rid =currentComment.get('pid') || currentComment.get('rid');
if (!rid) {
console.log("这条评论没有 @ 任何人");
return;
} else if (currentComment.get('isSpam')) {
console.log('评论未通过审核,通知邮件暂不发送');
return;
}
let query = new AV.Query('Comment');
query.get(rid).then(function (parentComment) {
if (parentComment.get('mail') && parentComment.get('mail') !== process.env.BLOGGER_EMAIL) {
mail.send(currentComment, parentComment);
} else {
console.log('被@者匿名,不会发送通知');
}
}, function (error) {
console.warn('获取@对象失败!');
});
}
router.get('/mark-spam', function (req, res, next) {
if (req.currentUser) {
let query = new AV.Query(Comment);
query.get(req.query.id).then(function (object) {
object.set('isSpam', true);
object.set('ACL', {"*":{"read":false}} );
object.save();
spam.submitSpam(object);
res.redirect('/comments')
}, function (err) {
}).catch(next);
} else {
res.redirect('/');
}
});
async findChannels () {
let userToChannelQuery = new AV.Query('UserToChannel')
let results = await userToChannelQuery.equalTo('user', this.Object).find()
return results.map(userToChannel => {
return userToChannel.get('channelName')
})
}
const createQuery = () => {
return new AV.Query(Post)
}
AV.Cloud.define('getPostWithAuthor', async request => {
const post = await new AV.Query(Post).get(request.params.id)
const user = await fetchUserFromCache(post.get('author').id)
return _.extend(post.toJSON(), {
author: user
})
})
exports.update = function (params, cb) {
if ((Date.now() - params.time) < 60 * 60 * 1000) {
return cb('更新频率过高');
}
var query = new AV.Query('Token');
query.first().then(function(res) {
var GHTOKEN = res.get('token');
var cmds = [];
try {
var stat = fs.statSync('surge-hosts');
if (stat.isDirectory()) {
cmds = [
'cd hosts && git pull',
'cd surge-hosts && git pull',
'cd ipv6-hosts && git pull'
];
} else {
cmds = [
'rm -rf hosts surge-hosts ipv6-hosts',
'git clone --depth 1 --branch master --single-branch https://github.com/googlehosts/hosts.git',
'git clone --depth 1 --branch master --single-branch https://github.com/lennylxx/ipv6-hosts.git',
const queryArticle = (id) => {
const query = new AV.Query('ContentList')
return query.get(id)
}
const queryTags = () => {
const query = new AV.Query('Tags')
return query.find()
}