Merge branch 'master' into develop

This commit is contained in:
Julian Lam
2017-02-24 12:46:40 -05:00
449 changed files with 9202 additions and 6984 deletions

View File

@@ -11,15 +11,14 @@ var plugins = require('../plugins');
var flags = require('../flags');
module.exports = function (Posts) {
Posts.delete = function (pid, uid, callback) {
var postData;
async.waterfall([
function (next) {
plugins.fireHook('filter:post.delete', {pid: pid, uid: uid}, next);
plugins.fireHook('filter:post.delete', { pid: pid, uid: uid }, next);
},
function (data, next) {
Posts.setPostFields(pid, {deleted: 1, deleterUid: uid}, next);
Posts.setPostFields(pid, { deleted: 1, deleterUid: uid }, next);
},
function (next) {
Posts.getPostFields(pid, ['pid', 'tid', 'uid', 'timestamp'], next);
@@ -39,13 +38,13 @@ module.exports = function (Posts) {
},
function (next) {
topics.updateTeaser(postData.tid, next);
}
},
], next);
},
function (results, next) {
plugins.fireHook('action:post.delete', {post: _.clone(postData), uid: uid});
plugins.fireHook('action:post.delete', { post: _.clone(postData), uid: uid });
next(null, postData);
}
},
], callback);
};
@@ -53,10 +52,10 @@ module.exports = function (Posts) {
var postData;
async.waterfall([
function (next) {
plugins.fireHook('filter:post.restore', {pid: pid, uid: uid}, next);
plugins.fireHook('filter:post.restore', { pid: pid, uid: uid }, next);
},
function (data, next) {
Posts.setPostFields(pid, {deleted: 0, deleterUid: 0}, next);
Posts.setPostFields(pid, { deleted: 0, deleterUid: 0 }, next);
},
function (next) {
Posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'timestamp'], next);
@@ -76,13 +75,13 @@ module.exports = function (Posts) {
},
function (next) {
topics.updateTeaser(postData.tid, next);
}
},
], next);
},
function (results, next) {
plugins.fireHook('action:post.restore', {post: _.clone(postData), uid: uid});
plugins.fireHook('action:post.restore', { post: _.clone(postData), uid: uid });
next(null, postData);
}
},
], callback);
};
@@ -111,7 +110,7 @@ module.exports = function (Posts) {
} else {
next();
}
}
},
], callback);
}
@@ -124,7 +123,7 @@ module.exports = function (Posts) {
if (!exists) {
return callback();
}
plugins.fireHook('filter:post.purge', {pid: pid, uid: uid}, next);
plugins.fireHook('filter:post.purge', { pid: pid, uid: uid }, next);
},
function (data, next) {
async.parallel([
@@ -145,7 +144,7 @@ module.exports = function (Posts) {
},
function (next) {
db.sortedSetsRemove(['posts:pid', 'posts:flagged'], pid, next);
}
},
], function (err) {
next(err);
});
@@ -154,9 +153,9 @@ module.exports = function (Posts) {
Posts.getPostData(pid, next);
},
function (postData, next) {
plugins.fireHook('action:post.purge', {post: postData, uid: uid});
plugins.fireHook('action:post.purge', { post: postData, uid: uid });
db.delete('post:' + pid, next);
}
},
], callback);
};
@@ -171,7 +170,7 @@ module.exports = function (Posts) {
db.sortedSetsRemove([
'tid:' + postData.tid + ':posts',
'tid:' + postData.tid + ':posts:votes',
'uid:' + postData.uid + ':posts'
'uid:' + postData.uid + ':posts',
], pid, next);
},
function (next) {
@@ -205,9 +204,9 @@ module.exports = function (Posts) {
},
function (next) {
notifications.rescind('new_post:tid:' + postData.tid + ':pid:' + pid + ':uid:' + postData.uid, next);
}
},
], next);
}
},
], function (err) {
callback(err);
});
@@ -254,7 +253,7 @@ module.exports = function (Posts) {
},
downvoters: function (next) {
db.getSetMembers('pid:' + pid + ':downvote', next);
}
},
}, function (err, results) {
if (err) {
return callback(err);
@@ -277,7 +276,7 @@ module.exports = function (Posts) {
},
function (next) {
db.deleteAll(['pid:' + pid + ':upvote', 'pid:' + pid + ':downvote'], next);
}
},
], callback);
});
}
@@ -292,10 +291,8 @@ module.exports = function (Posts) {
}
async.parallel([
async.apply(db.sortedSetRemove, 'pid:' + toPid + ':replies', pid),
async.apply(db.decrObjectField, 'post:' + toPid, 'replies')
async.apply(db.decrObjectField, 'post:' + toPid, 'replies'),
], callback);
});
}
};