mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #5398
This commit is contained in:
@@ -73,7 +73,7 @@ module.exports = function (Categories) {
|
|||||||
next(null, category);
|
next(null, category);
|
||||||
},
|
},
|
||||||
function (category, next) {
|
function (category, next) {
|
||||||
plugins.fireHook('action:category.create', category);
|
plugins.fireHook('action:category.create', {category: category});
|
||||||
next(null, category);
|
next(null, category);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module.exports = function (Categories) {
|
|||||||
purgeCategory(cid, next);
|
purgeCategory(cid, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
plugins.fireHook('action:category.delete', cid);
|
plugins.fireHook('action:category.delete', {cid: cid, uid: uid});
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ authenticationController.onSuccessfulLogin = function (req, uid, callback) {
|
|||||||
// Force session check for all connected socket.io clients with the same session id
|
// Force session check for all connected socket.io clients with the same session id
|
||||||
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);
|
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);
|
||||||
|
|
||||||
plugins.fireHook('action:user.loggedIn', uid);
|
plugins.fireHook('action:user.loggedIn', {uid: uid, req: req});
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ module.exports = function (Groups) {
|
|||||||
async.series(tasks, next);
|
async.series(tasks, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
plugins.fireHook('action:group.create', groupData);
|
plugins.fireHook('action:group.create', {group: groupData});
|
||||||
next(null, groupData);
|
next(null, groupData);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ module.exports = function (Groups) {
|
|||||||
}
|
}
|
||||||
var groupObj = groupsData[0];
|
var groupObj = groupsData[0];
|
||||||
|
|
||||||
plugins.fireHook('action:group.destroy', groupObj);
|
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
async.apply(db.delete, 'group:' + groupName),
|
async.apply(db.delete, 'group:' + groupName),
|
||||||
async.apply(db.sortedSetRemove, 'groups:createtime', groupName),
|
async.apply(db.sortedSetRemove, 'groups:createtime', groupName),
|
||||||
@@ -45,6 +43,7 @@ module.exports = function (Groups) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
Groups.resetCache();
|
Groups.resetCache();
|
||||||
|
plugins.fireHook('action:group.destroy', {group: groupObj});
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ module.exports = function (Plugins) {
|
|||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
meta.reloadRequired = true;
|
meta.reloadRequired = true;
|
||||||
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', id);
|
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', {id: id});
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
], function (err) {
|
], function (err) {
|
||||||
@@ -95,7 +95,7 @@ module.exports = function (Plugins) {
|
|||||||
Plugins.get(id, next);
|
Plugins.get(id, next);
|
||||||
},
|
},
|
||||||
function (pluginData, next) {
|
function (pluginData, next) {
|
||||||
Plugins.fireHook('action:plugin.' + type, id);
|
Plugins.fireHook('action:plugin.' + type, {id: id, version: version});
|
||||||
next(null, pluginData);
|
next(null, pluginData);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ var plugins = require('./plugins');
|
|||||||
pid: pid
|
pid: pid
|
||||||
};
|
};
|
||||||
data[field] = value;
|
data[field] = value;
|
||||||
plugins.fireHook('action:post.setFields', data);
|
plugins.fireHook('action:post.setFields', {data: data});
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -167,7 +167,7 @@ var plugins = require('./plugins');
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
data.pid = pid;
|
data.pid = pid;
|
||||||
plugins.fireHook('action:post.setFields', data);
|
plugins.fireHook('action:post.setFields', {data: data});
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -168,10 +168,11 @@ SocketAdmin.config.setMultiple = function (socket, data, callback) {
|
|||||||
key: field,
|
key: field,
|
||||||
value: data[field]
|
value: data[field]
|
||||||
};
|
};
|
||||||
plugins.fireHook('action:config.set', setting);
|
|
||||||
logger.monitorConfig({io: index.server}, setting);
|
logger.monitorConfig({io: index.server}, setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plugins.fireHook('action:config.set', {settings: data});
|
||||||
setImmediate(next);
|
setImmediate(next);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
var _ = require('underscore');
|
||||||
var validator = require('validator');
|
var validator = require('validator');
|
||||||
var S = require('string');
|
var S = require('string');
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
@@ -82,7 +83,7 @@ module.exports = function (Topics) {
|
|||||||
], next);
|
], next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
plugins.fireHook('action:topic.save', topicData);
|
plugins.fireHook('action:topic.save', {topic: _.clone(topicData)});
|
||||||
next(null, topicData.tid);
|
next(null, topicData.tid);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
@@ -174,7 +175,7 @@ module.exports = function (Topics) {
|
|||||||
data.postData.index = 0;
|
data.postData.index = 0;
|
||||||
|
|
||||||
analytics.increment(['topics', 'topics:byCid:' + data.topicData.cid]);
|
analytics.increment(['topics', 'topics:byCid:' + data.topicData.cid]);
|
||||||
plugins.fireHook('action:topic.post', data.topicData);
|
plugins.fireHook('action:topic.post', {topic: data.topicData, post: data.postData});
|
||||||
|
|
||||||
if (parseInt(uid, 10)) {
|
if (parseInt(uid, 10)) {
|
||||||
user.notifications.sendTopicNotificationToFollowers(uid, data.topicData, data.postData);
|
user.notifications.sendTopicNotificationToFollowers(uid, data.topicData, data.postData);
|
||||||
@@ -269,7 +270,7 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
Topics.notifyFollowers(postData, uid);
|
Topics.notifyFollowers(postData, uid);
|
||||||
analytics.increment(['posts', 'posts:byCid:' + cid]);
|
analytics.increment(['posts', 'posts:byCid:' + cid]);
|
||||||
plugins.fireHook('action:topic.reply', postData);
|
plugins.fireHook('action:topic.reply', {post: _.clone(postData)});
|
||||||
|
|
||||||
next(null, postData);
|
next(null, postData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,18 +114,18 @@ module.exports = function (Topics) {
|
|||||||
function toggleLock(tid, uid, lock, callback) {
|
function toggleLock(tid, uid, lock, callback) {
|
||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
|
|
||||||
var cid;
|
var topicData;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
Topics.getTopicField(tid, 'cid', next);
|
Topics.getTopicFields(tid, ['tid', 'uid', 'cid'], next);
|
||||||
},
|
},
|
||||||
function (_cid, next) {
|
function (_topicData, next) {
|
||||||
cid = _cid;
|
topicData = _topicData;
|
||||||
if (!cid) {
|
if (!topicData || !topicData.cid) {
|
||||||
return next(new Error('[[error:no-topic]]'));
|
return next(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
privileges.categories.isAdminOrMod(cid, uid, next);
|
privileges.categories.isAdminOrMod(topicData.cid, uid, next);
|
||||||
},
|
},
|
||||||
function (isAdminOrMod, next) {
|
function (isAdminOrMod, next) {
|
||||||
if (!isAdminOrMod) {
|
if (!isAdminOrMod) {
|
||||||
@@ -135,16 +135,11 @@ module.exports = function (Topics) {
|
|||||||
Topics.setTopicField(tid, 'locked', lock ? 1 : 0, next);
|
Topics.setTopicField(tid, 'locked', lock ? 1 : 0, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
var data = {
|
topicData.isLocked = lock;
|
||||||
tid: tid,
|
|
||||||
isLocked: lock,
|
|
||||||
uid: uid,
|
|
||||||
cid: cid
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins.fireHook('action:topic.lock', data);
|
plugins.fireHook('action:topic.lock', {topic: _.clone(topicData), uid: uid});
|
||||||
|
|
||||||
next(null, data);
|
next(null, topicData);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
}
|
}
|
||||||
@@ -167,7 +162,7 @@ module.exports = function (Topics) {
|
|||||||
if (!exists) {
|
if (!exists) {
|
||||||
return callback(new Error('[[error:no-topic]]'));
|
return callback(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
Topics.getTopicFields(tid, ['cid', 'lastposttime', 'postcount'], next);
|
Topics.getTopicFields(tid, ['uid', 'tid', 'cid', 'lastposttime', 'postcount'], next);
|
||||||
},
|
},
|
||||||
function (_topicData, next) {
|
function (_topicData, next) {
|
||||||
topicData = _topicData;
|
topicData = _topicData;
|
||||||
@@ -198,16 +193,12 @@ module.exports = function (Topics) {
|
|||||||
], next);
|
], next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
var data = {
|
|
||||||
tid: tid,
|
|
||||||
isPinned: pin,
|
|
||||||
uid: uid,
|
|
||||||
cid: topicData.cid
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins.fireHook('action:topic.pin', data);
|
topicData.isPinned = pin;
|
||||||
|
|
||||||
next(null, data);
|
plugins.fireHook('action:topic.pin', {topic: _.clone(topicData), uid: uid});
|
||||||
|
|
||||||
|
next(null, topicData);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ module.exports = function (User) {
|
|||||||
if (userNameChanged) {
|
if (userNameChanged) {
|
||||||
User.notifications.sendNameChangeNotification(userData.uid, userData.username);
|
User.notifications.sendNameChangeNotification(userData.uid, userData.username);
|
||||||
}
|
}
|
||||||
plugins.fireHook('action:user.create', userData);
|
plugins.fireHook('action:user.create', {user: userData});
|
||||||
next(null, userData.uid);
|
next(null, userData.uid);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user