mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
working author import
This commit is contained in:
parent
b8648b4a49
commit
0676d2fe24
1 changed files with 21 additions and 13 deletions
|
@ -24,19 +24,27 @@ exports.setPadRaw = function(padId, records, callback){
|
||||||
async.eachSeries(Object.keys(records), function(key, cb){
|
async.eachSeries(Object.keys(records), function(key, cb){
|
||||||
var value = records[key]
|
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(":");
|
var oldPadId = key.split(":");
|
||||||
oldPadId[1] = padId;
|
|
||||||
|
// we know its pad data..
|
||||||
if(oldPadId[0] === "pad"){
|
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
|
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
|
// Write the value to the server
|
||||||
db.set(newKey, value);
|
db.set(newKey, value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue