hooks: Call the callback when done

If a hook function neither calls the callback nor returns a
(non-undefined) value then there's no way for the hook system to know
if/when the hook function has finished.
This commit is contained in:
Richard Hansen 2020-10-10 22:51:26 -04:00 committed by John McLear
parent 55939a0d7e
commit 79119baf58
15 changed files with 26 additions and 6 deletions

View file

@ -5,5 +5,5 @@ exports.expressCreateServer = function (hook_name, args, cb) {
if('/' != req.path[req.path.length-1]) return res.redirect('./admin/'); if('/' != req.path[req.path.length-1]) return res.redirect('./admin/');
res.send( eejs.require("ep_etherpad-lite/templates/admin/index.html", {}) ); res.send( eejs.require("ep_etherpad-lite/templates/admin/index.html", {}) );
}); });
return cb();
} }

View file

@ -27,6 +27,8 @@ exports.expressCreateServer = function(hook_name, args, cb) {
latestVersion: UpdateCheck.getLatestVersion() latestVersion: UpdateCheck.getLatestVersion()
})); }));
}); });
return cb();
} }
exports.socketio = function(hook_name, args, cb) { exports.socketio = function(hook_name, args, cb) {
@ -111,6 +113,7 @@ exports.socketio = function(hook_name, args, cb) {
}); });
}); });
}); });
return cb();
} }
function sortPluginList(plugins, property, /*ASC?*/dir) { function sortPluginList(plugins, property, /*ASC?*/dir) {

View file

@ -15,6 +15,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
res.send( eejs.require("ep_etherpad-lite/templates/admin/settings.html", render_args) ); res.send( eejs.require("ep_etherpad-lite/templates/admin/settings.html", render_args) );
}); });
return cb();
} }
exports.socketio = function (hook_name, args, cb) { exports.socketio = function (hook_name, args, cb) {
@ -53,4 +54,5 @@ exports.socketio = function (hook_name, args, cb) {
}); });
}); });
return cb();
} }

View file

@ -29,4 +29,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/api', function (req, res) { args.app.get('/api', function (req, res) {
res.json({"currentVersion" : apiHandler.latestApiVersion}); res.json({"currentVersion" : apiHandler.latestApiVersion});
}); });
return cb();
} }

View file

@ -12,4 +12,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
console.error(err.stack? err.stack : err.toString()); console.error(err.stack? err.stack : err.toString());
stats.meter('http500').mark() stats.meter('http500').mark()
}); });
return cb();
} }

View file

@ -71,4 +71,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
} }
await importHandler.doImport(req, res, req.params.pad); await importHandler.doImport(req, res, req.params.pad);
}); });
return cb();
} }

View file

@ -532,7 +532,7 @@ const generateDefinitionForVersion = (version, style = APIPathStyle.FLAT) => {
return definition; return definition;
}; };
exports.expressCreateServer = async (_, args) => { exports.expressCreateServer = (hookName, args, cb) => {
const { app } = args; const { app } = args;
// create openapi-backend handlers for each api version under /api/{version}/* // create openapi-backend handlers for each api version under /api/{version}/*
@ -687,6 +687,7 @@ exports.expressCreateServer = async (_, args) => {
}); });
} }
} }
return cb();
}; };
// helper to get api root // helper to get api root

View file

@ -22,5 +22,5 @@ exports.expressCreateServer = function (hook_name, args, cb) {
res.send(html); res.send(html);
} }
}); });
return cb();
} }

View file

@ -26,4 +26,5 @@ exports.expressCreateServer = function (hook_name, args, cb) {
res.status(302).send('You should be redirected to <a href="' + real_url + '">' + real_url + '</a>'); res.status(302).send('You should be redirected to <a href="' + real_url + '">' + real_url + '</a>');
} }
}); });
return cb();
} }

View file

@ -72,4 +72,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
socketIORouter.addComponent("pad", padMessageHandler); socketIORouter.addComponent("pad", padMessageHandler);
hooks.callAll("socketio", {"app": args.app, "io": io, "server": args.server}); hooks.callAll("socketio", {"app": args.app, "io": io, "server": args.server});
return cb();
} }

View file

@ -87,5 +87,5 @@ exports.expressCreateServer = function (hook_name, args, cb) {
}); });
}); });
return cb();
} }

View file

@ -55,4 +55,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
res.write(JSON.stringify({"plugins": clientPlugins, "parts": clientParts})); res.write(JSON.stringify({"plugins": clientPlugins, "parts": clientParts}));
res.end(); res.end();
}); });
return cb();
} }

View file

@ -61,6 +61,8 @@ exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/tests/frontend', function (req, res) { args.app.get('/tests/frontend', function (req, res) {
res.redirect('/tests/frontend/index.html'); res.redirect('/tests/frontend/index.html');
}); });
return cb();
} }
const readdir = util.promisify(fs.readdir); const readdir = util.promisify(fs.readdir);

View file

@ -198,4 +198,5 @@ exports.checkAccess = (req, res, next) => {
exports.expressConfigure = (hook_name, args, cb) => { exports.expressConfigure = (hook_name, args, cb) => {
args.app.use(exports.checkAccess); args.app.use(exports.checkAccess);
return cb();
}; };

View file

@ -100,7 +100,7 @@ var generateLocaleIndex = function (locales) {
} }
exports.expressCreateServer = function(n, args) { exports.expressCreateServer = function(n, args, cb) {
//regenerate locales on server restart //regenerate locales on server restart
var locales = getAllLocales(); var locales = getAllLocales();
@ -123,5 +123,5 @@ exports.expressCreateServer = function(n, args) {
res.send(localeIndex); res.send(localeIndex);
}) })
return cb();
} }