From cb6522499734afe156d1e5b660858d93645fb8c6 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 00:28:00 +0000 Subject: [PATCH] better logic for author handling --- src/node/utils/ImportEtherpad.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/node/utils/ImportEtherpad.js b/src/node/utils/ImportEtherpad.js index 8daeb5363..1574a3a9d 100644 --- a/src/node/utils/ImportEtherpad.js +++ b/src/node/utils/ImportEtherpad.js @@ -24,12 +24,25 @@ exports.setPadRaw = function(padId, records, callback){ async.eachSeries(Object.keys(records), function(key, cb){ var value = records[key] - // we know its an author + // Author data if(value.padIDs){ // rewrite author pad ids value.padIDs[padId] = 1; var newKey = key; + // Does this author already exist? + db.get(key, function(err, author){ + if(author){ + // Yes, add the padID to the author.. + author.padIDs.push(padId); + value = author; + }else{ + // No, create a new array with the author info in + value.padIDs = [padId]; + } + }); + + // Not author data, probably pad data }else{ // we can split it to look to see if its pad data var oldPadId = key.split(":");