Merge remote-tracking branch 'refs/remotes/origin/master' into develop

# Conflicts:
#	package.json
This commit is contained in:
Baris Usakli
2017-07-13 15:02:23 -04:00
35 changed files with 212 additions and 154 deletions

View File

@@ -10,7 +10,6 @@ var events = require('./events');
var Reset = {};
Reset.reset = function (callback) {
db.init(function (err) {
if (err) {
@@ -163,10 +162,14 @@ function resetPlugins(callback) {
}
function resetWidgets(callback) {
require('./widgets').reset(function (err) {
winston.info('[reset] All Widgets moved to Draft Zone');
callback(err);
});
async.waterfall([
require('./plugins').reload,
require('./widgets').reset,
function (next) {
winston.info('[reset] All Widgets moved to Draft Zone');
next();
},
], callback);
}
module.exports = Reset;

View File

@@ -326,12 +326,10 @@ Topics.isLocked = function (tid, callback) {
};
Topics.search = function (tid, term, callback) {
if (plugins.hasListeners('filter:topic.search')) {
plugins.fireHook('filter:topic.search', {
tid: tid,
term: term,
}, callback);
} else {
callback(new Error('[[error:no-plugins-available]]'), []);
}
plugins.fireHook('filter:topic.search', {
tid: tid,
term: term,
}, function (err, pids) {
callback(err, Array.isArray(pids) ? pids : []);
});
};

View File

@@ -34,8 +34,72 @@ module.exports = {
}).filter(Boolean);
winston.verbose('[2016/04/29] ' + toDismiss.length + ' dismissable flags found');
async.each(toDismiss, posts.dismissFlag, next);
async.each(toDismiss, dismissFlag, next);
},
], callback);
},
};
// copied from core since this function was removed
// https://github.com/NodeBB/NodeBB/blob/v1.x.x/src/posts/flags.js
function dismissFlag(pid, callback) {
async.waterfall([
function (next) {
db.getObjectFields('post:' + pid, ['pid', 'uid', 'flags'], next);
},
function (postData, next) {
if (!postData.pid) {
return callback();
}
async.parallel([
function (next) {
if (parseInt(postData.uid, 10)) {
if (parseInt(postData.flags, 10) > 0) {
async.parallel([
async.apply(db.sortedSetIncrBy, 'users:flags', -postData.flags, postData.uid),
async.apply(db.incrObjectFieldBy, 'user:' + postData.uid, 'flags', -postData.flags),
], next);
} else {
next();
}
} else {
next();
}
},
function (next) {
db.sortedSetsRemove([
'posts:flagged',
'posts:flags:count',
'uid:' + postData.uid + ':flag:pids',
], pid, next);
},
function (next) {
async.series([
function (next) {
db.getSortedSetRange('pid:' + pid + ':flag:uids', 0, -1, function (err, uids) {
if (err) {
return next(err);
}
async.each(uids, function (uid, next) {
var nid = 'post_flag:' + pid + ':uid:' + uid;
async.parallel([
async.apply(db.delete, 'notifications:' + nid),
async.apply(db.sortedSetRemove, 'notifications', 'post_flag:' + pid + ':uid:' + uid),
], next);
}, next);
});
},
async.apply(db.delete, 'pid:' + pid + ':flag:uids'),
], next);
},
async.apply(db.deleteObjectField, 'post:' + pid, 'flags'),
async.apply(db.delete, 'pid:' + pid + ':flag:uid:reason'),
async.apply(db.deleteObjectFields, 'post:' + pid, ['flag:state', 'flag:assignee', 'flag:notes', 'flag:history']),
], next);
},
function (results, next) {
db.sortedSetsRemoveRangeByScore(['users:flags'], '-inf', 0, next);
},
], callback);
}

View File

@@ -70,7 +70,7 @@ function renderWidget(widget, uid, options, callback) {
}
},
function (config, next) {
var templateData = _.assign(options.templateData, { config: config });
var templateData = _.assign({ }, options.templateData, { config: config });
plugins.fireHook('filter:widget.render:' + widget.widget, {
uid: uid,
area: options,
@@ -193,7 +193,7 @@ widgets.reset = function (callback) {
function (results, next) {
drafts = results.drafts || [];
async.each(results.areas, function (area, next) {
async.eachSeries(results.areas, function (area, next) {
async.waterfall([
function (next) {
widgets.getArea(area.template, area.location, next);