Skip to content

Commit

Permalink
Changeset: Move changeset logic to a new Changeset class
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen committed Nov 22, 2021
1 parent a5ba53f commit 410d02e
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 125 deletions.
5 changes: 2 additions & 3 deletions src/node/handler/PadMessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,10 @@ const handleUserChanges = async (socket, message) => {
const wireApool = (new AttributePool()).fromJsonable(apool);
const pad = await padManager.getPad(thisSession.padId);

// Verify that the changeset has valid syntax and is in canonical form
Changeset.checkRep(changeset);
const cs = Changeset.unpack(changeset).validate();

// Validate all added 'author' attribs to be the same value as the current user
for (const op of Changeset.deserializeOps(Changeset.unpack(changeset).ops)) {
for (const op of Changeset.deserializeOps(cs.ops)) {
// + can add text with attribs
// = can change or add attribs
// - can have attribs, but they are discarded and don't show up in the attribs -
Expand Down
2 changes: 1 addition & 1 deletion src/node/utils/padDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
}
}

return Changeset.checkRep(builder.toString());
return builder.build().validate().toString();
};

// export the constructor
Expand Down
Loading

0 comments on commit 410d02e

Please sign in to comment.