mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
attempting to get right client authorid sent with changeset
This commit is contained in:
parent
85c68b1f51
commit
12a2da2884
1 changed files with 36 additions and 0 deletions
|
@ -26,6 +26,8 @@ var Changeset = require('./Changeset');
|
||||||
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//console.log("CS", Changeset);
|
||||||
|
|
||||||
// latest official text from server
|
// latest official text from server
|
||||||
var baseAText = Changeset.makeAText("\n");
|
var baseAText = Changeset.makeAText("\n");
|
||||||
// changes applied to baseText that have been submitted
|
// changes applied to baseText that have been submitted
|
||||||
|
@ -161,6 +163,40 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Get my authorID
|
||||||
|
var authorId = parent.parent.pad.myUserInfo.userId;
|
||||||
|
// Rewrite apool authors with my author information
|
||||||
|
|
||||||
|
// We need to replace apool numToAttrib array where first value is author
|
||||||
|
// With thisSession.author
|
||||||
|
var numToAttr = apool.numToAttrib;
|
||||||
|
if(numToAttr){
|
||||||
|
for (var attr in numToAttr){
|
||||||
|
if (numToAttr[attr][0] === 'author'){
|
||||||
|
// We force write the author over a change, for sanity n stuff
|
||||||
|
apool.numToAttrib[attr][1] = authorId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the actual author is the AuthorID
|
||||||
|
// We need to replace apool attrToNum value where the first value before
|
||||||
|
// the comma is author with authorId
|
||||||
|
var attrToNum = apool.attribToNum;
|
||||||
|
if(attrToNum){
|
||||||
|
for (var attr in attrToNum){
|
||||||
|
var splitAttr = attr.split(',');
|
||||||
|
var isAuthor = (splitAttr[0] === 'author'); // Is it an author val?
|
||||||
|
if (isAuthor){
|
||||||
|
// We force write the author over a change, for sanity n stuff
|
||||||
|
var newValue = 'author,'+authorId; // Create a new value
|
||||||
|
var key = attrToNum[attr]; // Key is actually the value
|
||||||
|
delete apool.attribToNum[attr]; // Delete the old value
|
||||||
|
apool.attribToNum[newValue] = key; // Write a new value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Changeset.isIdentity(userChangeset)) toSubmit = null;
|
if (Changeset.isIdentity(userChangeset)) toSubmit = null;
|
||||||
else toSubmit = userChangeset;
|
else toSubmit = userChangeset;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue