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,7 +11,6 @@ var privileges = require('./privileges');
var plugins = require('./plugins');
(function (Posts) {
require('./posts/create')(Posts);
require('./posts/delete')(Posts);
require('./posts/edit')(Posts);
@@ -43,7 +42,7 @@ var plugins = require('./plugins');
var keys = [];
for (var x = 0, numPids = pids.length; x < numPids; ++x) {
for (var x = 0, numPids = pids.length; x < numPids; x += 1) {
keys.push('post:' + pids[x]);
}
@@ -65,7 +64,7 @@ var plugins = require('./plugins');
}, next);
},
function (posts, next) {
plugins.fireHook('filter:post.getPosts', {posts: posts, uid: uid}, next);
plugins.fireHook('filter:post.getPosts', { posts: posts, uid: uid }, next);
},
function (data, next) {
if (!data || !Array.isArray(data.posts)) {
@@ -73,7 +72,7 @@ var plugins = require('./plugins');
}
data.posts = data.posts.filter(Boolean);
next(null, data.posts);
}
},
], callback);
};
@@ -86,11 +85,11 @@ var plugins = require('./plugins');
privileges.posts.filter('read', pids, uid, next);
},
function (pids, next) {
Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next);
Posts.getPostSummaryByPids(pids, uid, { stripTags: false }, next);
},
function (posts, next) {
next(null, {posts: posts, nextStart: stop + 1});
}
next(null, { posts: posts, nextStart: stop + 1 });
},
], callback);
};
@@ -122,7 +121,7 @@ var plugins = require('./plugins');
data.pid = pid;
plugins.fireHook('filter:post.getFields', {posts: [data], fields: fields}, function (err, data) {
plugins.fireHook('filter:post.getFields', { posts: [data], fields: fields }, function (err, data) {
callback(err, (data && Array.isArray(data.posts) && data.posts.length) ? data.posts[0] : null);
});
});
@@ -141,7 +140,7 @@ var plugins = require('./plugins');
if (err) {
return callback(err);
}
plugins.fireHook('filter:post.getFields', {posts: posts, fields: fields}, function (err, data) {
plugins.fireHook('filter:post.getFields', { posts: posts, fields: fields }, function (err, data) {
callback(err, (data && Array.isArray(data.posts)) ? data.posts : null);
});
});
@@ -153,7 +152,7 @@ var plugins = require('./plugins');
return callback(err);
}
var data = {
pid: pid
pid: pid,
};
data[field] = value;
plugins.fireHook('action:post.setFields', {data: data});
@@ -211,12 +210,12 @@ var plugins = require('./plugins');
db[method](sets, pids, next);
},
function (indices, next) {
for (var i = 0; i < indices.length; ++i) {
for (var i = 0; i < indices.length; i += 1) {
indices[i] = utils.isNumber(indices[i]) ? parseInt(indices[i], 10) + 1 : 0;
}
next(null, indices);
}
},
], callback);
};
@@ -246,12 +245,12 @@ var plugins = require('./plugins');
return next();
}
db.sortedSetAdd('tid:' + postData.tid + ':posts:votes', postData.votes, postData.pid, next);
}
},
], next);
},
function (next) {
Posts.setPostFields(postData.pid, {upvotes: postData.upvotes, downvotes: postData.downvotes}, next);
}
Posts.setPostFields(postData.pid, { upvotes: postData.upvotes, downvotes: postData.downvotes }, next);
},
], function (err) {
callback(err);
});
@@ -265,6 +264,4 @@ var plugins = require('./plugins');
}
}
};
}(exports));