ot server patch

Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
Raccoon 2021-06-12 13:18:51 +08:00
parent a10263b13e
commit 74f9e57148
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38

View File

@ -479,6 +479,10 @@ function buildAuthorProfilesFromNote(noteAuthors) {
function makeNewServerNote(note) {
const authors = buildAuthorProfilesFromNote(note.authors)
const otServer = new ot.EditorSocketIOServer(note.content, [], note.id, ifMayEdit, operationCallback)
otServer.debug = config.debug
otServer.setLogger(logger)
otServer.setDocumentMaxLength(config.documentmaxlength)
return {
id: note.id,
@ -494,7 +498,7 @@ function makeNewServerNote(note) {
tempUsers: {},
createtime: moment(note.createdAt).valueOf(),
updatetime: moment(note.lastchangeAt).valueOf(),
server: new ot.EditorSocketIOServer(note.content, [], note.id, ifMayEdit, operationCallback),
server: otServer,
authors: authors,
authorship: note.authorship
}
@ -652,6 +656,7 @@ function operationCallback(socket, operation) {
return logger.error('operation callback failed: ' + err)
})
}
note.server.isDirty = true
note.tempUsers[userId] = Date.now()
}
// save authorship - use timer here because it's an O(n) complexity algorithm