From 90bcd65a002be9f628c0220c216c0426cb7e2767 Mon Sep 17 00:00:00 2001 From: Jakub <25460763+oplik0@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:20:37 +0200 Subject: [PATCH] add filter:manifest.build (#7821) * add filter:manifest.build Added a hook that lets plugins modify manifest.json, as suggested in https://community.nodebb.org/post/59670 * Added error handling Thanks barisusakli * Define next * Pass data as an object * Remove multiple spaces --- src/controllers/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index f304b4d840..200d7c9070 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -267,7 +267,7 @@ Controllers.robots = function (req, res) { } }; -Controllers.manifest = function (req, res) { +Controllers.manifest = function (req, res, next) { var manifest = { name: meta.config.title || 'NodeBB', start_url: nconf.get('relative_path') + '/', @@ -309,8 +309,12 @@ Controllers.manifest = function (req, res) { density: 4.0, }); } - - res.status(200).json(manifest); + plugins.fireHook('filter:manifest.build', { req: req, res: res, manifest: manifest }, function (err, data) { + if (err) { + return next(err); + } + res.status(200).json(data.manifest); + }); }; Controllers.outgoing = function (req, res, next) {