diff --git a/src/node/utils/ExportEtherpad.js b/src/node/utils/ExportEtherpad.js index 99d86140f..0bc2bf04a 100644 --- a/src/node/utils/ExportEtherpad.js +++ b/src/node/utils/ExportEtherpad.js @@ -22,6 +22,8 @@ var ERR = require("async-stacktrace"); exports.getPadRaw = function(padId, callback){ async.waterfall([ function(cb){ + + // Get the Pad available content keys db.findKeys("pad:"+padId+"*", null, function(err,records){ if(!err){ cb(err, records); @@ -30,15 +32,37 @@ exports.getPadRaw = function(padId, callback){ }, function(records, cb){ var data = {}; + async.forEachSeries(Object.keys(records), function(key, r){ + + // For each piece of info about a pad. db.get(records[key], function(err, entry){ data[records[key]] = entry; + + // Get the Pad Authors + if(entry.pool && entry.pool.numToAttrib){ + var authors = entry.pool.numToAttrib; + async.forEachSeries(Object.keys(authors), function(k, c){ + if(authors[k][0] === "author"){ + var authorId = authors[k][1]; + + // Get the author info + db.get("globalAuthor:"+authorId, function(e, authorEntry){ + if(!e) data["globalAuthor:"+authorId] = authorEntry; + }); + + } + // console.log("authorsK", authors[k]); + c(null); + }); + } r(null); // callback; }); }, function(err){ cb(err, data); }) - }], function(err, data){ + } + ], function(err, data){ callback(null, data); }); }