working author import

pull/2418/head
John McLear 2014-12-30 00:01:15 +01:00
parent b8648b4a49
commit 0676d2fe24
1 changed files with 21 additions and 13 deletions

View File

@ -24,19 +24,27 @@ exports.setPadRaw = function(padId, records, callback){
async.eachSeries(Object.keys(records), function(key, cb){
var value = records[key]
// rewrite padId
// we know its an author
if(value.padIDs){
// rewrite author pad ids
value.padIDs[padId] = 1;
var newKey = key;
}else{
// we can split it to look to see if its pad data
var oldPadId = key.split(":");
oldPadId[1] = padId;
// we know its pad data..
if(oldPadId[0] === "pad"){
// so set the new pad id for the author
oldPadId[1] = padId;
// and create the value
var newKey = oldPadId.join(":"); // create the new key
}
// Add the author to this new pad
if(oldPadId[0] === "globalAuthor"){
value.padIDs[padId] = 1 ;
var newKey = value;
}
// Write the value to the server
db.set(newKey, value);