@@ -251,13 +251,13 @@ function getStatus(callback) {
251251 return logger . error ( 'count user failed: ' + err ) ;
252252 } ) ;
253253 } ) . catch ( function ( err ) {
254- return logger . error ( 'count note failed: ' + err ) ;
254+ return logger . error ( 'count note failed: ' + err ) ;
255255 } ) ;
256256}
257257
258258function isReady ( ) {
259- return realtime . io
260- && Object . keys ( notes ) . length == 0 && Object . keys ( users ) . length == 0
259+ return realtime . io
260+ && Object . keys ( notes ) . length == 0 && Object . keys ( users ) . length == 0
261261 && connectionSocketQueue . length == 0 && ! isConnectionBusy
262262 && disconnectSocketQueue . length == 0 && ! isDisconnectBusy ;
263263}
@@ -420,7 +420,7 @@ function finishConnection(socket, note, user) {
420420function startConnection ( socket ) {
421421 if ( isConnectionBusy ) return ;
422422 isConnectionBusy = true ;
423-
423+
424424 var noteId = socket . noteId ;
425425 if ( ! noteId ) {
426426 return failConnection ( 404 , 'note id not found' , socket ) ;
@@ -521,7 +521,7 @@ function disconnect(socket) {
521521 logger . info ( "SERVER disconnected a client" ) ;
522522 logger . info ( JSON . stringify ( users [ socket . id ] ) ) ;
523523 }
524-
524+
525525 if ( users [ socket . id ] ) {
526526 delete users [ socket . id ] ;
527527 }
@@ -618,12 +618,12 @@ function ifMayEdit(socket, callback) {
618618 case "freely" :
619619 //not blocking anyone
620620 break ;
621- case "editable" :
621+ case "editable" : case : "limited" :
622622 //only login user can change
623623 if ( ! socket . request . user || ! socket . request . user . logged_in )
624624 mayEdit = false ;
625625 break ;
626- case "locked" : case "private" :
626+ case "locked" : case "private" : case "protected" :
627627 //only owner can change
628628 if ( ! note . owner || note . owner != socket . request . user . id )
629629 mayEdit = false ;
@@ -672,7 +672,7 @@ function operationCallback(socket, operation) {
672672 var noteId = note . alias ? note . alias : LZString . compressToBase64 ( note . id ) ;
673673 if ( note . server ) history . updateHistory ( userId , noteId , note . server . document ) ;
674674 } , 0 ) ;
675-
675+
676676 }
677677 // save authorship
678678 note . authorship = models . Note . updateAuthorshipByOperation ( operation , userId , note . authorship ) ;
@@ -689,10 +689,10 @@ function connection(socket) {
689689 }
690690
691691 if ( isDuplicatedInSocketQueue ( socket , connectionSocketQueue ) ) return ;
692-
692+
693693 // store noteId in this socket session
694694 socket . noteId = noteId ;
695-
695+
696696 //initialize user data
697697 //random color
698698 var color = randomcolor ( ) ;
0 commit comments