mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
Added private permission and clean up codes, solved potential race condition in realtime.js
This commit is contained in:
parent
473212676a
commit
49c7dded45
6 changed files with 297 additions and 199 deletions
|
@ -43,6 +43,7 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
|
|||
socket.on('operation', function (revision, operation, selection) {
|
||||
operation = LZString.decompressFromUTF16(operation);
|
||||
operation = JSON.parse(operation);
|
||||
socket.origin = 'operation';
|
||||
self.mayWrite(socket, function (mayWrite) {
|
||||
if (!mayWrite) {
|
||||
console.log("User doesn't have the right to edit.");
|
||||
|
@ -59,6 +60,7 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
|
|||
self.onGetOperations(socket, base, head);
|
||||
});
|
||||
socket.on('selection', function (obj) {
|
||||
socket.origin = 'selection';
|
||||
self.mayWrite(socket, function (mayWrite) {
|
||||
if (!mayWrite) {
|
||||
console.log("User doesn't have the right to edit.");
|
||||
|
@ -104,6 +106,7 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
|
|||
'operation', clientId, revision,
|
||||
wrappedPrime.wrapped.toJSON(), wrappedPrime.meta
|
||||
);
|
||||
//set document is dirty
|
||||
this.isDirty = true;
|
||||
} catch (exc) {
|
||||
logger.error(exc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue