diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 51d38d99..6ebb3010 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -332,11 +332,6 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) { } }; - // include in layergroup response the variables in serverMedata - // those variables are useful to send to the client information - // about how to reach this server or information about it - _.extend(layergroup, global.environment.serverMetadata); - // Don't wait for the mapview count increment to // take place before proceeding. Error will be logged // asynchronously @@ -349,7 +344,11 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) { }); step( - function getAffectedTables () { + function () { + self.augmentLayergroupData(req, res, this); + }, + function getAffectedTables (err) { + assert.ifError(err); self.getAffectedTables(req, res, this); }, function setCacheChannel (err) { @@ -374,6 +373,17 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) { ); }; +MapController.prototype.augmentLayergroupData = function (req, res, callback) { + const { layergroup } = res.locals; + + // include in layergroup response the variables in serverMedata + // those variables are useful to send to the client information + // about how to reach this server or information about it + _.extend(layergroup, global.environment.serverMetadata); + + callback(); +} + MapController.prototype.getAffectedTables = function (req, res, callback) { const self = this; const { dbname, layergroup, user, mapconfig } = res.locals;