v1.18.x
barisusakli 8 years ago
parent a143a15f5d
commit 3fb7f9fce5

@ -73,7 +73,7 @@ module.exports = function (Categories) {
next(null, category);
},
function (category, next) {
plugins.fireHook('action:category.create', category);
plugins.fireHook('action:category.create', {category: category});
next(null, category);
}
], callback);

@ -31,7 +31,7 @@ module.exports = function (Categories) {
purgeCategory(cid, next);
},
function (next) {
plugins.fireHook('action:category.delete', cid);
plugins.fireHook('action:category.delete', {cid: cid, uid: uid});
next();
}
], 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
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);
plugins.fireHook('action:user.loggedIn', uid);
plugins.fireHook('action:user.loggedIn', {uid: uid, req: req});
callback();
});
};

@ -70,7 +70,7 @@ module.exports = function (Groups) {
async.series(tasks, next);
},
function (results, next) {
plugins.fireHook('action:group.create', groupData);
plugins.fireHook('action:group.create', {group: groupData});
next(null, groupData);
}
], callback);

@ -17,8 +17,6 @@ module.exports = function (Groups) {
}
var groupObj = groupsData[0];
plugins.fireHook('action:group.destroy', groupObj);
async.parallel([
async.apply(db.delete, 'group:' + groupName),
async.apply(db.sortedSetRemove, 'groups:createtime', groupName),
@ -45,6 +43,7 @@ module.exports = function (Groups) {
return callback(err);
}
Groups.resetCache();
plugins.fireHook('action:group.destroy', {group: groupObj});
callback();
});
});

@ -50,7 +50,7 @@ module.exports = function (Plugins) {
},
function (next) {
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();
}
], function (err) {
@ -95,7 +95,7 @@ module.exports = function (Plugins) {
Plugins.get(id, next);
},
function (pluginData, next) {
Plugins.fireHook('action:plugin.' + type, id);
Plugins.fireHook('action:plugin.' + type, {id: id, version: version});
next(null, pluginData);
}
], callback);

@ -156,7 +156,7 @@ var plugins = require('./plugins');
pid: pid
};
data[field] = value;
plugins.fireHook('action:post.setFields', data);
plugins.fireHook('action:post.setFields', {data: data});
callback();
});
};
@ -167,7 +167,7 @@ var plugins = require('./plugins');
return callback(err);
}
data.pid = pid;
plugins.fireHook('action:post.setFields', data);
plugins.fireHook('action:post.setFields', {data: data});
callback();
});
};

@ -168,10 +168,11 @@ SocketAdmin.config.setMultiple = function (socket, data, callback) {
key: field,
value: data[field]
};
plugins.fireHook('action:config.set', setting);
logger.monitorConfig({io: index.server}, setting);
}
}
plugins.fireHook('action:config.set', {settings: data});
setImmediate(next);
}
], callback);

@ -2,6 +2,7 @@
'use strict';
var async = require('async');
var _ = require('underscore');
var validator = require('validator');
var S = require('string');
var db = require('../database');
@ -82,7 +83,7 @@ module.exports = function (Topics) {
], next);
},
function (results, next) {
plugins.fireHook('action:topic.save', topicData);
plugins.fireHook('action:topic.save', {topic: _.clone(topicData)});
next(null, topicData.tid);
}
], callback);
@ -174,7 +175,7 @@ module.exports = function (Topics) {
data.postData.index = 0;
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)) {
user.notifications.sendTopicNotificationToFollowers(uid, data.topicData, data.postData);
@ -269,7 +270,7 @@ module.exports = function (Topics) {
Topics.notifyFollowers(postData, uid);
analytics.increment(['posts', 'posts:byCid:' + cid]);
plugins.fireHook('action:topic.reply', postData);
plugins.fireHook('action:topic.reply', {post: _.clone(postData)});
next(null, postData);
}

@ -114,18 +114,18 @@ module.exports = function (Topics) {
function toggleLock(tid, uid, lock, callback) {
callback = callback || function () {};
var cid;
var topicData;
async.waterfall([
function (next) {
Topics.getTopicField(tid, 'cid', next);
Topics.getTopicFields(tid, ['tid', 'uid', 'cid'], next);
},
function (_cid, next) {
cid = _cid;
if (!cid) {
function (_topicData, next) {
topicData = _topicData;
if (!topicData || !topicData.cid) {
return next(new Error('[[error:no-topic]]'));
}
privileges.categories.isAdminOrMod(cid, uid, next);
privileges.categories.isAdminOrMod(topicData.cid, uid, next);
},
function (isAdminOrMod, next) {
if (!isAdminOrMod) {
@ -135,16 +135,11 @@ module.exports = function (Topics) {
Topics.setTopicField(tid, 'locked', lock ? 1 : 0, next);
},
function (next) {
var data = {
tid: tid,
isLocked: lock,
uid: uid,
cid: cid
};
topicData.isLocked = lock;
plugins.fireHook('action:topic.lock', data);
plugins.fireHook('action:topic.lock', {topic: _.clone(topicData), uid: uid});
next(null, data);
next(null, topicData);
}
], callback);
}
@ -167,7 +162,7 @@ module.exports = function (Topics) {
if (!exists) {
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) {
topicData = _topicData;
@ -198,16 +193,12 @@ module.exports = function (Topics) {
], 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);
}

@ -141,7 +141,7 @@ module.exports = function (User) {
if (userNameChanged) {
User.notifications.sendNameChangeNotification(userData.uid, userData.username);
}
plugins.fireHook('action:user.create', userData);
plugins.fireHook('action:user.create', {user: userData});
next(null, userData.uid);
}
], callback);

Loading…
Cancel
Save